package cn.stylefeng.guns.base;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.util.ObjectUtil;
import cn.stylefeng.guns.GunsApplication;
import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.core.util.DateUtil;
import cn.stylefeng.guns.sys.core.util.*;
import cn.stylefeng.guns.sys.modular.system.ApiEntity.*;
import cn.stylefeng.guns.sys.modular.system.db2.entity.Student;
import cn.stylefeng.guns.sys.modular.system.db2.mapper.BizMapper;
import cn.stylefeng.guns.sys.modular.system.db2.model.result.BizResult;
import cn.stylefeng.guns.sys.modular.system.db2.service.BizService;
import cn.stylefeng.guns.sys.modular.system.db2.service.StudentService;
import cn.stylefeng.guns.sys.modular.system.entity.*;
import cn.stylefeng.guns.sys.modular.system.mapper.*;
import cn.stylefeng.guns.sys.modular.system.model.params.*;
import cn.stylefeng.guns.sys.modular.system.model.result.*;
import cn.stylefeng.guns.sys.modular.system.service.*;
import cn.stylefeng.roses.core.util.ToolUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dingtalk.api.response.OapiAttendanceGetcolumnvalResponse;
import com.dingtalk.api.response.OapiAttendanceListResponse;
import com.dingtalk.api.response.OapiDepartmentListResponse;
import com.dingtalk.api.response.OapiUserSimplelistResponse;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.lang3.time.DateUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.jdom2.Document;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.WebApplicationContext;

import javax.annotation.Resource;
import java.io.*;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

import static cn.stylefeng.guns.sys.core.util.DownloadUtil.saveUrlAs;
import static cn.stylefeng.guns.sys.core.util.SignEncryptDncryptSignChk.*;
import static cn.stylefeng.guns.sys.core.util.ZipUtil.unZipFiles;


/**
 * 基础测试类
 *
 * @author stylefeng
 * @Date 2017/5/21 16:10
 */
@RunWith(SpringRunner.class)
@SpringBootTest(classes = GunsApplication.class)
@WebAppConfiguration
//@Transactional //打开的话测试之后数据可自动回滚
public class BaseJunit {
    private Logger logger = LoggerFactory.getLogger(BaseJunit.class);
    @Autowired
    WebApplicationContext webApplicationContext;

    @Autowired
    private BtyHykService hykService;

    @Autowired
    private CompanyInfoService companyInfoService;


    @Autowired
    private BankService bankService;

    @Autowired
    private ItemTypeService itemTypeService;

    @Autowired
    private ItemInterfaceService itemInterfaceService;

    @Autowired
    private DsstoreBillService dsstoreBillService;

    @Autowired
    private BtyShopTreeService btyShopTreeService;

    @Autowired
    private BtyShopService btyShopService;

    @Autowired
    private ItemUnitService itemUnitService;

    @Autowired
    private StudentService studentService;

    @Autowired
    private WeChatSendTempMsgService weChatSendTempMsgService;

    @Autowired
    private RedisUtils redisUtils;
    @Resource
    private YybbService yybbService;
    @Resource
    private BankTestService bankTestService;
    @Resource
    private ProjectMapper projectMapper;
    @Resource
    private BtyYfdService btyYfdService;

    @Resource
    private BtySsyyeService ssyyeService;
    @Resource
    private BtyHycyService hycyService;
    @Resource
    private BizMapper bizMapper;
    @Resource
    private BizService bizService;
    @Resource
    private BtyDyMapper dyMapper;
    @Resource
    private BtyElmsxfMapper elmsxfMapper;
    @Resource
    private BtyEkbService ekbService;
    @Resource
    private BtyElmMapper elmMapper;
    @Resource
    private YybbMapper yybbMapper;
    @Resource
    private  BtyPsdService psdService;

    @Resource
    private BtyBrandMapper btyBrandMapper;
    @Resource
    private BtyShdkmxMapper shdkmxMapper;
    @Resource
    private BtyPjkMapper pjkMapper;
    @Resource
    private BtyBankyebService btyBankyebService;
    @Resource
    private BtyDyskService btyDyskService;
    @Resource
    private BtyDyskMapper btyDyskMapper;
    @Resource
    private BtyBxdaService btyBxdaService;
    @Resource
    private BtyDysxfMapper dysxfMapper;
    @Resource
    private ProjectService projectService;
    @Resource
    private BtyWmhService btyWmhService;
    @Resource
    private BtyDoubleCardMapper doubleCardMapper;
    @Resource
    private TaskFlowService taskFlowService;


    protected MockMvc mockMvc;

    @Before
    public void setupMockMvc() {
        mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
    }

    @Before
    public void initDatabase() {
    }

    /**
     * 初始化区域树父级
     */
    @Test
    public void initAreaPids() {
        //areaService.initAreaPids();
    }

    /**
     * 初始化品类数据
     */
    @Test
    public void initItemTypeData() {
        itemTypeService.initItemTypeData();
    }

    /**
     * 初始化品项数据
     */
    @Test
    public void initIntemInferfaceData() {
        itemInterfaceService.initIntemInferfaceData();
    }

    /**
     * 门店库存流水集市数据导入测试
     */
    @Test
    public void initDsstorebillData() {

        try {
            List<String> dateList = DateUtil.getBetweenDate("2021-01-02", "2021-01-03");
            logger.info("门店库存流水定时任务-开始执行数据写入,日期：{}", dateList.toString());
            Map<String, Integer> map = dsstoreBillService.initDsstorebillData(dateList);
            logger.info("门店库存流水定时任务-结束执行数据写入,{}", map.toString());
        } catch (Exception e) {
            logger.info("门店库存流水定时任务，写入数据失败");
            e.printStackTrace();
        }

    }


    /**
     * 门店库存流水集市---当日进货量金额统计
     */
    @Test
    public void initDsstorebillPurchaseData() {

        try {
            List<String> dateList = DateUtil.getBetweenDate("2021-01-02", "2021-01-06");
            logger.info("门店库存流水定时任务-当日进货量金额统计-开始执行数据写入,日期：{}", dateList.toString());
            Map<String, Integer> map = dsstoreBillService.initDsstorebillPurchaseData(dateList);
            logger.info("门店库存流水定时任务-当日进货量金额统计-结束执行数据写入,{}", map.toString());
        } catch (Exception e) {
            logger.info("门店库存流水定时任务-当日进货量金额统计，写入数据失败");
            e.printStackTrace();
        }

    }


    /**
     * 拉取数据-门店数据-并生成门店树数据
     */
    @Test
    public void initShopData() {
        try {
            logger.info("门店数据入库-开始执行");
            btyShopService.initShopData();
            logger.info("门店数据入库结束-结束执行");
            //初始化门店树
            btyShopTreeService.initShopTeeData();
        } catch (Exception e) {
            logger.info("初始化门店树数据失败");
            e.printStackTrace();
        }

    }

    /**
     * 拉取数据-分公司档案数据
     */
    @Test
    public void initCompanyInfoData() {
        logger.info("分公司档案数据入库-开始执行");
        companyInfoService.initCompanyInfoData();
        logger.info("分公司档案数据入库-结束执行");
    }

    /**
     * 初始化门店树数据ShopTeeData
     */
    @Test
    public void initShopTeeData() {
        btyShopTreeService.initShopTeeData();
    }

    /**
     * 初始化品项单位数据
     */
    @Test
    public void initItemUnitData() {
        logger.info("初始化品项单位数据-开始执行");
        itemUnitService.initItemUnitData();
        logger.info("初始化品项单位数据-结束执行");
    }


    /**
     * 为shopTree赋值shopCode
     */
    @Test
    public void setShopCodes() {
        btyShopTreeService.setShopCodes();
    }

    /**
     * 测试库存获取 本期结存数据 结果
     */
    @Test
    public void getConutDataResult() {
        DsstoreBillParam param = new DsstoreBillParam();
        param.setShopCode("023");
        param.setItemTypeCode("101");
        param.setStartTime("2020-09-01");
        param.setStartTime("2020-09-16");
        dsstoreBillService.getConutDataResult(param);
    }

    @Test
    public void sendMsgTest() {
        String[] strs = {"11111111111111111", "2222222222", DateUtil.getNow(), "3333333333"};
        JSONObject param = weChatSendTempMsgService.setTempParam("4444444444", "http://rs.bantianyaozg.com/", strs);
        String[] openids = {"oJnvX6bl1QpALDNj4lFbryBcZ-kA"};
        weChatSendTempMsgService.sendmsg(openids, "http://rs.bantianyaozg.com", param);
    }

    @Test
    public void testMuli() {
        List<Student> students = studentService.testMul();

        System.out.println(students.toArray());

        System.out.println("===============0-00000============----=============3030==========================--399953==========");

        DsstoreBillParam param = new DsstoreBillParam();
        param.setShopCode("023");
        param.setItemTypeCode("101");
        param.setStartTime("2020-09-01");
        param.setStartTime("2020-09-16");
        LayuiPageInfo conutDataResult = dsstoreBillService.getConutDataResult(param);


        List<Student> studentss = studentService.testMul();


        Student stu = new Student();
        LayuiPageInfo pageBySpec = studentService.findPageBySpec(stu);

        System.out.println(pageBySpec.getCount());
        System.out.println(studentss.toArray());

        System.out.println("===============0-00000============----=============3030==========================--399953==========");

        DsstoreBillParam param1 = new DsstoreBillParam();
        param1.setShopCode("023");
        param1.setItemTypeCode("101");
        param1.setStartTime("2020-09-01");
        param1.setStartTime("2020-09-16");
        dsstoreBillService.getConutDataResult(param1);


    }


    @Test
    public void testRedis() {
        Object test1 = redisUtils.get("test");
        redisUtils.set("test", "1");


        Object test = redisUtils.get("test");
        System.out.println(test);

    }

    @Test
    public void testStrSpi() {

        String str = "前厅耗品300.0000，前厅耗品300.0000";
        String target = "前厅耗300.0000";

        List<String> strList = Arrays.asList(str.split("，"));
        List arrList = new ArrayList(strList);


        Iterator<String> iter = arrList.iterator();
        while (iter.hasNext()) {
            String item = iter.next();
            if (item.equals(target)) {
                iter.remove();
                break;
            }
        }
        Object collect = arrList.stream().collect(Collectors.joining("，"));

        String resultStr = collect.toString();
        if (arrList.size() > 0) {
            resultStr = resultStr + "，";
        }

        System.out.println(arrList.toString());

    }


    @Test
    public void testSplitYinHangCard() {

        String string = "0123456789abcd23423422343534";
        StringBuilder str = new StringBuilder(string.replace(" ", ""));
        int i = str.length() / 4;
        int j = str.length() % 4;
        for (int x = (j == 0 ? i - 1 : i); x > 0; x--) {
            str = str.insert(x * 4, " ");
        }
        System.out.println(str);
    }


    @Test
    public void testListFuZhi() {
        ArrayList<DsstoreBillParam> list = new ArrayList<DsstoreBillParam>();
        DsstoreBillParam param = new DsstoreBillParam();
        param.setAPYear(1L);
        param.setGiftFlag(1);
        list.add(param);


        ArrayList<DsstoreBillParam> tmpList = (ArrayList<DsstoreBillParam>) list.clone();

        for (DsstoreBillParam param1 : tmpList) {
            Long year = param1.getAPYear();
            param1.setAPYear(year + 1);
            Integer flag = param1.getGiftFlag();
            param1.setGiftFlag(flag);
        }

        System.out.println();

    }

    @Test
    public void testsubmonth() throws ParseException {

        String s = DateUtil.lastMonthByDate("2020-12-01");
        System.out.println(s);
        s = DateUtil.lastMonthByDate(s);
        System.out.println(s);
        s = DateUtil.lastMonthByDate(s);
        System.out.println(s);
    }


    /**
     * 门店初期单缓存
     *
     * @throws ParseException
     */
    @Test
    public void initDsstorebillChuQiDanData() throws ParseException {
        logger.info("初始化月末结转期初单数据-开始执行");
        dsstoreBillService.initDsstorebillChuQiDanData();
        logger.info("初始化月末结转期初单数据-结束执行");
    }

    @Test
    public void cmbcTest() {
        try {
            RestTemplate restTemplate = new RestTemplate();
            String dates = DateUtil.getStampNow();
            String date = dates.substring(0, 8);
            String time = dates.substring(dates.length() - 6);
            String yesterdayDate = DateUtil.getYesterDay();
            //子账簿交易查询
            String context = "{\"platformId\":\"M23002021040001171743\",\"merchantNo\":\"M23002021040001171743\"," +
                    "\"contractId\":\"20210425185836171743\",\"outOptSeq\":\"23002021040001171743b87271ea4c00498c952a87ba3bab82\",\"transDate\":\"" + date + "\",\"transTime\":\"" + time + "\"" +
                    ",\"accNo\":\"9734000008775375\",\"totalNum\":\"200\",\"dcFlag\":\"2\",\"detStat\":\"00\",\"startDate\":\"" + yesterdayDate + "\",\"endDate\":\"" + yesterdayDate + "\"}";
//            String context="{\"platformId\":\"M23002021040001171743\",\"merchantNo\":\"M23002021040001171743\"," +
//                    "\"contractId\":\"20210425185836171743\",\"outOptSeq\":\"23002021040001171743b87271ea4c00498c952a87ba3bab82\",\"transDate\":\""+date+"\",\"transTime\":\""+time+"\"" +
//                    ",\"accNo\":\"9734000008775375\",\"totalNum\":\"200\",\"dcFlag\":\"2\",\"detStat\":\"00\",\"startDate\":\"20210504\",\"endDate\":\"20210504\"}";
            //签名
            String sign = getSign(context);
            System.out.println("--------------------------------------");
            System.out.println("签名：");
            System.out.println(sign);
            //加密前
            String signContext = SignEncryptDncryptSignChk.sign(sign, context);
            System.out.println("--------------------------------------");
            System.out.println("加密前：");
            System.out.println(signContext);
            //加密后
            String encryptContext = encrypt(signContext);
            System.out.println("--------------------------------------");
            System.out.println("加密后：");
            System.out.println(encryptContext);

            JSONObject json = new JSONObject();
            json.put("businessContext", encryptContext);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            String url = "https://epay.cmbc.com.cn/appweb/bill/subBookTradeQry.do";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            String flag = jo.get("gateReturnType").getAsString();
            Integer currNum = 0;
            Integer totalPage = 0;
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

            String todayDate = sdf.format(new Date());

            if (flag.equals("S")) {
                String businessContext = jo.get("businessContext").getAsString();
                String dncryptContexts = dncrypt(businessContext);
                System.out.println("--------------------------------------");
                System.out.println("解密后111：");
                System.out.println(dncryptContexts);

                JsonObject jos = jp.parse(dncryptContexts).getAsJsonObject();

                String body = jos.get("body").getAsString();
                JSONObject jsonObject = JSON.parseObject(body);
                currNum = Integer.parseInt(jsonObject.getString("currNum"));
                totalPage = Integer.parseInt(jsonObject.getString("totalPage"));
                //数组对象反序列化成集合
                List<CmbcData> list = JSON.parseArray(jsonObject.getString("outList"), CmbcData.class);
                System.out.println("currNum:" + currNum);
                System.out.println("listsize:" + list.size());
                System.out.println(list.get(0).getPayeeAccNo() + "======" + list.get(0).getTranAmount());
                for (CmbcData cmbcData : list) {
                    Bank bank = new Bank();
                    bank.setRq(yesterdayDate);
                    bank.setSr(new BigDecimal(cmbcData.getTranAmount()));
                    bank.setZy(cmbcData.getPostscript());
                    bank.setZh(cmbcData.getDraweeAccNo());
                    bank.setHm(cmbcData.getDraweeAccName());
                    bank.setZzh(cmbcData.getPayeeAccNo());
                    bank.setZmc(cmbcData.getPayeeAccName());
                    bank.setCl(1);
                    bank.setRiqi(DateUtil.getDateByStr(todayDate));
                    bank.setCzy("孔利霞");
                    bankService.save(bank);

                }
//                while(currNum<totalPage) {
//                    currNum++;
//                    cmbc(currNum);
//                }
            }

        } catch (ParseException e) {
            e.printStackTrace();
        }
    }

    public void cmbc(Integer currNum) {
        try {
            RestTemplate restTemplate = new RestTemplate();
            String dates = DateUtil.getStampNow();
            String date = dates.substring(0, 8);
            String time = dates.substring(dates.length() - 6);
            String yesterdayDate = DateUtil.getYesterDay();
            //子账簿交易查询
            String context = "{\"platformId\":\"M23002021040001171743\",\"merchantNo\":\"M23002021040001171743\"," +
                    "\"contractId\":\"20210425185836171743\",\"outOptSeq\":\"23002021040001171743b87271ea4c00498c952a87ba3bab82\",\"transDate\":\"" + date + "\",\"transTime\":\"" + time + "\"" +
                    ",\"accNo\":\"9734000008775375\",\"totalNum\":\"200\",\"dcFlag\":\"2\",\"detStat\":\"00\",\"startDate\":\"" + yesterdayDate + "\",\"endDate\":\"" + yesterdayDate + "\"}";
//            String context="{\"platformId\":\"M23002021040001171743\",\"merchantNo\":\"M23002021040001171743\"," +
//                    "\"contractId\":\"20210425185836171743\",\"outOptSeq\":\"23002021040001171743b87271ea4c00498c952a87ba3bab82\",\"transDate\":\""+date+"\",\"transTime\":\""+time+"\"" +
//                    ",\"accNo\":\"9734000008775375\",\"startNum\":\""+currNum+"\",\"totalNum\":\"200\",\"dcFlag\":\"2\",\"detStat\":\"00\",\"startDate\":\"20210504\",\"endDate\":\"20210504\"}";
            //签名
            String sign = getSign(context);
            System.out.println("--------------------------------------");
            System.out.println("签名：");
            System.out.println(sign);
            //加密前
            String signContext = SignEncryptDncryptSignChk.sign(sign, context);
            System.out.println("--------------------------------------");
            System.out.println("加密前：");
            System.out.println(signContext);
            //加密后
            String encryptContext = encrypt(signContext);
            System.out.println("--------------------------------------");
            System.out.println("加密后：");
            System.out.println(encryptContext);

            JSONObject json = new JSONObject();
            json.put("businessContext", encryptContext);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            String url = "https://epay.cmbc.com.cn/appweb/bill/subBookTradeQry.do";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            String flag = jo.get("gateReturnType").getAsString();
            //Integer totalCount =jo.get("totalCount").getAsInt();
            // Integer currNum =Integer.parseInt(jo.get("currNum").getAsString());
            // Integer totalPage =Integer.parseInt(jo.get("totalPage").getAsString());

            if (flag.equals("S")) {
                String businessContext = jo.get("businessContext").getAsString();
                String dncryptContexts = dncrypt(businessContext);
                System.out.println("--------------------------------------");
                System.out.println("解密后111：");
                System.out.println(dncryptContexts);

                JsonObject jos = jp.parse(dncryptContexts).getAsJsonObject();
                String body = jos.get("body").getAsString();
                JSONObject jsonObject = JSON.parseObject(body);
                //数组对象反序列化成集合
                List<CmbcData> list = JSON.parseArray(jsonObject.getString("outList"), CmbcData.class);
                System.out.println("listsize:" + list.size());
                System.out.println("currNum:" + currNum);
                System.out.println(list.get(0).getPayeeAccNo() + "======" + list.get(0).getTranAmount());
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Test
    public void crm() {
        //9276
        String yesterDayDate = DateUtil.getYesterDayDate();
        try {
            logger.info("====更新会员卡实际数据开始====");
            RestTemplate restTemplate = new RestTemplate();
            // 公钥
            String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwteCbSQgiIUwMZgX6Q5cGLCwH0i9Ou7bveU8JGuJcf416bVLpBZA6Hkdu47mxUETY3Bf4++yQ3khU0Il8JvtDp84AbAPEQI+qIoTF4Zm4Yytux6XLG8IYQWx1BBXNeDuuBl3d6q6cmgDz2zDX4IkF/HmAjBJuw3jCDMHwn/ZuNQIDAQAB";
            // 调用方id
            Integer productId = 1000002886;
            // 版本号
            String version = "1.0.0";
            Integer pageNo = 1;
            // 业务参数封装并加密
            JSONObject obj = new JSONObject();
            obj.put("companyId", 1000002886);
            obj.put("pageNo", pageNo);
            obj.put("pageCount", 9999);
            obj.put("tradeTime", "1");
            //获取消费类型的数据
            obj.put("tradeTypeId", 1);
            String sign = RsaUtil.encryptByPublicKey(obj.toJSONString(), publicKey);
            System.out.println("sign:" + sign);
            // 参数拼接在url后面
            String url = "https://scrm.wuuxiang.com/crm7api/api/trade/list.do?sign=" + sign + "&" + "productId=" + productId + "&" + "version=" + version;
            System.out.println("url:" + url);
            String result = restTemplate.getForObject(url, String.class);
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
//        //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            String list = jo.get("rpData").getAsJsonObject().get("list").toString();
            //System.out.println("list:" + list);
            List<HykData> lists = JSONArray.parseArray(list, HykData.class);
            // System.out.println("size:" + lists.size());
            //获取总页数
//            String pages=jo.get("rpData").getAsJsonObject().get("pages").getAsString();
//            Integer pageCount=Integer.parseInt(pages);
//            System.out.println("pages:"+pages);

            JSONObject obj30 = new JSONObject();
            obj30.put("companyId", 1000002886);
            obj30.put("pageNo", pageNo);
            obj30.put("pageCount", 9999);
            obj30.put("tradeTime", "1");
            //获取撤销消费类型的数据
            obj30.put("tradeTypeId", 30);
            String sign30 = RsaUtil.encryptByPublicKey(obj30.toJSONString(), publicKey);
            System.out.println("sign1:" + sign30);
            String url30 = "https://scrm.wuuxiang.com/crm7api/api/trade/list.do?sign=" + sign30 + "&" + "productId=" + productId + "&" + "version=" + version;
            String result30 = restTemplate.getForObject(url30, String.class);
            //System.out.println("result1:" + result1);
            //        //将json字符串转化成json对象
            JsonParser jp30 = new JsonParser();
            JsonObject jo30 = jp30.parse(result30).getAsJsonObject();
            String list30 = jo30.get("rpData").getAsJsonObject().get("list").toString();
            List<HykData> list31 = JSONArray.parseArray(list30, HykData.class);
            lists.addAll(list31);


            JSONObject obj1 = new JSONObject();
            obj1.put("companyId", 1000002886);
            obj1.put("pageNo", pageNo);
            obj1.put("pageCount", 9999);
            obj1.put("tradeTime", "1");
            //获取充值类型的数据
            obj1.put("tradeTypeId", 2);
            String sign1 = RsaUtil.encryptByPublicKey(obj1.toJSONString(), publicKey);
            System.out.println("sign1:" + sign1);
            String url1 = "https://scrm.wuuxiang.com/crm7api/api/trade/list.do?sign=" + sign1 + "&" + "productId=" + productId + "&" + "version=" + version;
            String result1 = restTemplate.getForObject(url1, String.class);
            //System.out.println("result1:" + result1);
            //        //将json字符串转化成json对象
            JsonParser jp1 = new JsonParser();
            JsonObject jo1 = jp1.parse(result1).getAsJsonObject();
            String list9 = jo1.get("rpData").getAsJsonObject().get("list").toString();
            List<HykData> list2 = JSONArray.parseArray(list9, HykData.class);
            lists.addAll(list2);

            JSONObject obj2 = new JSONObject();
            obj2.put("companyId", 1000002886);
            obj2.put("pageNo", pageNo);
            obj2.put("pageCount", 9999);
            obj2.put("tradeTime", "1");
            //获取撤销充值类型的数据
            obj2.put("tradeTypeId", 29);
            String sign2 = RsaUtil.encryptByPublicKey(obj2.toJSONString(), publicKey);
            String url2 = "https://scrm.wuuxiang.com/crm7api/api/trade/list.do?sign=" + sign2 + "&" + "productId=" + productId + "&" + "version=" + version;
            String result2 = restTemplate.getForObject(url2, String.class);
            //System.out.println("result1:" + result1);
            //        //将json字符串转化成json对象
            JsonParser jp2 = new JsonParser();
            JsonObject jo2 = jp2.parse(result2).getAsJsonObject();
            String list3 = jo2.get("rpData").getAsJsonObject().get("list").toString();
            List<HykData> list4 = JSONArray.parseArray(list3, HykData.class);
            lists.addAll(list4);

            //获取crm门店消费本金数据保存到bty_hyk表中
            for (HykData hykData : lists) {
                BtyHyk hyk = new BtyHyk();
                hyk.setId(UUIDUtils.getId());
                hyk.setDm(hykData.getXfShopName());
                if (ToolUtil.isNotEmpty(hykData.getExpandInfo())) {
                    if (ToolUtil.isNotEmpty(hykData.getExpandInfo().getConsumeCash())) {
                        hyk.setXfbj(hykData.getExpandInfo().getConsumeCash() == null ? BigDecimal.ZERO : hykData.getExpandInfo().getConsumeCash());
                    }
                }
                if (hykData.getTradeTypeId().equals("2") | hykData.getTradeTypeId().equals("29") && ToolUtil.isNotEmpty(hykData.getExpandInfo())) {
                    hyk.setCzje(hykData.getExpandInfo().getRechargeAmount() == null ? BigDecimal.ZERO : hykData.getExpandInfo().getRechargeAmount());
                }
                if (hykData.getTradeTypeId().equals("30") && ToolUtil.isNotEmpty(hykData.getExpandInfo())) {
                    hyk.setXfbj(hykData.getExpandInfo().getConsumeCash() == null ? BigDecimal.ZERO : hykData.getExpandInfo().getConsumeCash().multiply(new BigDecimal(-1)));
                }
                hyk.setJylx(hykData.getTradeTypeId());
                hyk.setCzlxmc(hykData.getTsTypeName());
                hyk.setJysj(hykData.getCreateTime());
                hyk.setYyr(yesterDayDate);
                hykService.save(hyk);
            }

            //获取bty_hyk表中的数据,更新会员卡消费本金金到yybb表中hyksj字段
            BtyHykParam param = new BtyHykParam();
            param.setYyr(yesterDayDate);
            List<BtyHykResult> list1 = hykService.listMdxfbj(param);
            if (list1.size() > 0) {
                for (BtyHykResult btyHykResult : list1) {
                    String dm = btyHykResult.getDm();
                    BigDecimal xfbj = btyHykResult.getXfbj();
                    Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                    if (ToolUtil.isNotEmpty(yybb)) {
                        yybb.setHyksj(xfbj);
                        yybbService.updateById(yybb);
                    }
                }
            }
            logger.info("====更新会员卡实际数据结束====");
        } catch (Exception e) {
            String err = e.getMessage();
            String data = "更新会员卡实际数据出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.info("====更新会员卡实际数据出现异常====" + e);
            e.printStackTrace();
        }

    }




    @Test
    public void salesDataQdTest() {
        try {
            logger.info("===更新青岛悦荟广场店数据开始...");
            String yesterday = DateUtil.getYesterDay4Oclock();
            String today = DateUtil.getToday4Oclock();
            Timestamp yesterdayTime = Timestamp.valueOf(yesterday);
            Timestamp todayTime = Timestamp.valueOf(today);
            //获取更新青岛悦荟广场店销售额
//        String money = bizService.lastMoneyByShopCode("403", yesterdayTime, todayTime);
//        if (ToolUtil.isEmpty(money)) {
//            money = "0";
//        }
            String money = "26635";
            //logger.info("青岛悦荟广场店销售额：" + money);
            //构造请求报文
            StringBuilder soap = new StringBuilder();
            String docKey = DateUtil.getStampNow();
            String ledgerDatetime = DateUtil.getDate(new Date());

            Qd.TransHeaderBean bean = new Qd.TransHeaderBean();
            String txDate = DateUtil.getYesterDayDate();
            bean.setTxDate("2021-08-10");
            bean.setLedgerDatetime(ledgerDatetime);
            bean.setStoreCode("tqd00320");
            bean.setTillId("01");
            bean.setDocNo(docKey);
            bean.setVoidDocNo("");
            bean.setTxAttrib("");

            Qd.SalesTotalBean salesTotalBean = new Qd.SalesTotalBean();
            salesTotalBean.setCashier("001");
            salesTotalBean.setVipCode("");
            BigDecimal netQty = new BigDecimal(1.0);
            BigDecimal netAmount = new BigDecimal(0.0);
            salesTotalBean.setNetQty(netQty);
            salesTotalBean.setNetAmount(netAmount);
            salesTotalBean.setExtendParameter(null);
            salesTotalBean.setCalculateVipBonus("0");


            List<Qd.SalesItemBean> list = new ArrayList<>();

            Qd.SalesItemBean salesItemBean = new Qd.SalesItemBean();
            salesItemBean.setSalesLineNumber(1);
            salesItemBean.setSalesman(null);
            salesItemBean.setItemCode("tqd0032001");
            salesItemBean.setItemOrgId("000007");
            salesItemBean.setItemLotNum("*");
            salesItemBean.setSerialNumber(null);
            salesItemBean.setInventoryType(0);
            salesItemBean.setQty(1);
            BigDecimal dec = new BigDecimal(0.0);
            salesItemBean.setItemDiscountLess(dec);
            salesItemBean.setTotalDiscountLess(dec);
            salesItemBean.setNetAmount(netAmount);
            salesItemBean.setSalesItemRemark(null);
            salesItemBean.setExtendParameter(null);
            list.add(salesItemBean);
            JSONObject salesItem = new JSONObject();
            salesItem.put("salesItem", list);

            List<Qd.SalesTenderBean> salesTenderBeanList = new ArrayList<>();
            Qd.SalesTenderBean salesTenderBean = new Qd.SalesTenderBean();
            salesTenderBean.setBaseCurrencyCode("RMB");
            salesTenderBean.setTenderCode("CH");
            salesTenderBean.setPayAmount(netAmount);
            salesTenderBean.setBaseAmount(netAmount);
            salesTenderBean.setExcessAmount(dec);
            salesTenderBean.setExtendParameter(null);
            salesTenderBeanList.add(salesTenderBean);


            JSONObject all = new JSONObject();
            all.put("apiKey", "CRMINT");
            all.put("signature", "");
            all.put("docKey", docKey);
            all.put("orgSalesMemo", null);
            all.put("transHeader", bean);
            all.put("salesTotal", salesTotalBean);
            all.put("salesItem", list);
            all.put("salesTender", salesTenderBeanList);


            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            System.out.println("all:" + all);
            HttpEntity<String> formEntity1 = new HttpEntity<String>(all.toString(), headers);
            //String url="http://180.166.29.82:8185/SalesTrans/rest/salestransaction/salestranslitev61";
            String url = "http://123.234.71.6:8185/SalesTrans/rest/salestransaction/salestranslitev61";
            String result = restTemplate.postForEntity(url, formEntity1, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String errcode = jo.get("errorCode").getAsString();
            String errmsg = jo.get("errorMessage").getAsString();
            if (errcode.equals("0")) {
                System.out.println("青岛悦荟广场店销售数据更新成功！");
                logger.info("===青岛悦荟广场店销售数据更新成功！");
            } else {
                System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
                logger.info("错误码：" + errcode + "错误信息:" + errmsg);
            }

        } catch (Exception e) {
            logger.error("更新青岛悦荟广场店销售数据 出现异常", e);
            e.printStackTrace();
        }
    }



    @Test
    public void readExcel() {
        try {
            //读取excel中的数据存到bank_jhsk表中
            String date = DateUtil.getYesterDay();
            //String date = "20210726";
            File file = new File("G:/CCB_EBSClient_B2C4FileCert_V5.9.3_Build20190827/download/SHOP.105003958129374." + date + " (Group Summary Statement).xlsx");
            InputStream is = new FileInputStream(file.getAbsoluteFile());
            //InputStream is = new FileInputStream(file);
            XSSFWorkbook wb = new XSSFWorkbook(is);
            XSSFSheet sheet = wb.getSheetAt(0);
            int lastRowNum = sheet.getLastRowNum();
            for (int r = 34; r <= lastRowNum; r++) {
                XSSFRow row = sheet.getRow(r);
                if (row == null) {
                    continue;
                }
//                for (int m = 1; m < 28; m++) {
//                    XSSFCell cell = row.getCell(m);
//                    if (ToolUtil.isNotEmpty(cell)) {
//                        cell.setCellType(CellType.STRING);
//                    }
//                }
                //场景标识
                String cjbs = row.getCell(7) == null ? "" : row.getCell(7).getStringCellValue();
                //终端号
                String zdh = row.getCell(4) == null ? "" : row.getCell(4).getStringCellValue();
                //交易日期
                String jyrq = row.getCell(16) == null ? "" : row.getCell(16).getStringCellValue();
                //交易时间
                String jysj = row.getCell(18) == null ? "" : row.getCell(18).getStringCellValue();
                //划账金额24/31
                String jyje = row.getCell(31) == null ? "" : row.getCell(31).getStringCellValue();
                //支付卡号
                String zfkh = row.getCell(35) == null ? "" : row.getCell(35).getStringCellValue();
                //订单编号
                String ddbh = row.getCell(36) == null ? "" : row.getCell(36).getStringCellValue();
                //商户柜台代码
                String shgtdm = row.getCell(37) == null ? "" : row.getCell(37).getStringCellValue();
                //手续费29列
                String sxf = row.getCell(29) == null ? "" : row.getCell(29).getStringCellValue();
                BankTest bankTest = new BankTest();
                if (jyje.contains(".")) {
                    if (ToolUtil.isNotEmpty(ddbh)) {
                        bankTest.setId(UUIDUtils.getId());
                        bankTest.setDdbh(ddbh);
                        bankTest.setZdh(zdh);
                        bankTest.setJyrq(jyrq);
                        bankTest.setJysj(jysj);
                        bankTest.setZfkh(zfkh);
                        bankTest.setJyje(jyje);
                        bankTest.setSxf(sxf);
                        bankTest.setCjbs(cjbs);
                        bankTest.setShgtdm(shgtdm);
                        bankTestService.save(bankTest);
                    }
                }
            }
            //获取bank_jhsk表中的数据,更新建行收款金额到yybb中
//             String yesterdayDate = DateUtil.getYesterDayDate();
//            //String yesterdayDate = "2021-07-18";
//            BankTestParam param = new BankTestParam();
//            param.setJyrq(yesterdayDate);
//            List<BankTestResult> list = bankTestService.listMdye(param);
//            for (BankTestResult bankTestResult : list) {
//                String dm = bankTestResult.getDm();
//                BigDecimal je = bankTestResult.getJyje();
//                BigDecimal sxf = bankTestResult.getYhksxf();
//                System.out.println("sxf:"+sxf);
//                Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterdayDate));
//                if (ToolUtil.isNotEmpty(yybb)) {
//                    yybb.setYhksj(je);
//                    yybb.setYhksxf(sxf);
//                    yybbService.updateById(yybb);
//                }
//
//            }
            logger.info("====更新建行收款结束====");
        } catch (IOException e) {
            String err = e.getMessage();
            String data = "更新建行收款出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.info("====更新建行收款出现异常====" + e);
            e.printStackTrace();
        }

    }

    @Test
    public void salesDataNh() {
        try {
            logger.info("===更新南湖数据开始...");
            String time = DateUtil.subtractTime(new Date(), -300000);
            System.out.println("time:" + time);
            String urls = "https://cysms.wuuxiang.com/api/auth/accesstoken?appid=e30659b3b3dc4ec5bede0f8100b402d1&accessid=1a2aba829e7841e3bddc383f28c40334&response_type=token";
            RestTemplate restTemplate = new RestTemplate();
            JSONObject jsonss = new JSONObject();
            HttpEntity<String> formEntityss = new HttpEntity<String>(jsonss.toString());
            String results = restTemplate.postForEntity(urls, formEntityss, String.class).getBody();
            //System.out.println("result:" + results);
            JSONObject jsonObject = JSONObject.parseObject(results);
            String accessToken = jsonObject.get("access_token").toString();
            System.out.println("accessToken:" + accessToken);
            //String timeBegin = DateUtil.getNow();
            String urlss = "https://cysms.wuuxiang.com/api/datatransfer/getserialdatalive?centerId=13289&shopId=83756&timeBegin=" + time + "";
            HttpHeaders header = new HttpHeaders();
            header.add("access_token", accessToken);
            header.add("accessid", "1a2aba829e7841e3bddc383f28c40334");
            header.add("granttype", "client");

            HttpEntity<String> formEntitys = new HttpEntity<>(header);
            String resultss = restTemplate.postForEntity(urlss, formEntitys, String.class).getBody();
            logger.info("南湖" + time + "result:" + resultss);
            Tcss tcss = restTemplate.postForEntity(urlss, formEntitys, Tcss.class).getBody();
            BigDecimal lastTotal = BigDecimal.ZERO;
            // System.out.println("results:"+tcss.getData().getShopBillList().get(0).getBillList().size());
            System.out.println("results:" + tcss.getData().getShopBillList().get(0).getBillList().size());


            if (tcss.getData().getShopBillList().get(0).getBillList().size() > 0) {
                List<Tcss.DataBean.ShopBillListBean.BillListBean> list = tcss.getData().getShopBillList().get(0).getBillList();
                for (Tcss.DataBean.ShopBillListBean.BillListBean billList : list) {
                    // BigDecimal yye= new BigDecimal(billList.getLast_total().toString());
                    // int num=yye.compareTo(BigDecimal.ZERO);
                    if (billList.getState().equals("1")) {
                        //String jssj=billList.getSettle_time().toString();
                        String jslsbh = billList.getBs_code();
                        List<BtySsyye> lists = ssyyeService.list(new QueryWrapper<BtySsyye>().eq("jslsbh", jslsbh));
                        System.out.println("lists.size:" + lists.size());
                        if (lists.size() <= 0) {
                            BtySsyye ssyye = new BtySsyye();
                            ssyye.setId(UUIDUtils.getId());
                            ssyye.setDm(billList.getShop_name());
                            ssyye.setYye(new BigDecimal(billList.getLast_total().toString()));
                            ssyye.setJssj(billList.getSettle_time().toString());
                            ssyye.setJslsbh(billList.getBs_code());
                            ssyyeService.save(ssyye);
                        }

                        lastTotal = lastTotal.add(new BigDecimal(billList.getLast_total().toString()));
                    }
                }
                System.out.println("销售额：" + lastTotal);
                //String state=tcss.getData().getShopBillList().get(0).getBillList()
            }
            String money = lastTotal.toString();
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            String now = sdf.format(new Date());
            String nowDate = DateUtil.getStampNow();
            logger.info("南湖销售额：" + money);
            String str[] = {};
            Map map = new HashMap();
            map.put("cardBank", "");
            map.put("cardNumber", "");
            map.put("discountAmt", 0);
            map.put("payAmt", money);
            map.put("paymentMethod", "CH");
            map.put("time", nowDate);
            map.put("value", money);
            List<Map<String, Object>> payList = new ArrayList<>();
            payList.add(map);

            //RestTemplate restTemplate = new RestTemplate();
            JSONObject dataJson = new JSONObject();
            //收银员编号
            dataJson.put("cashierId", "20122tvel117n0101");
            //店铺验证密钥
            dataJson.put("checkCode", "p88888888");
            //备注
            dataJson.put("comments", "comments");
            dataJson.put("itemList", str);
            //商场编号
            dataJson.put("mall", "20122");
            dataJson.put("mobile", "");
            //订单号
            dataJson.put("orderId", nowDate);
            System.out.println("订单号orderId:" + nowDate);
            dataJson.put("payList", payList);
            dataJson.put("refOrderId", "refOrderId");
            //店铺编号
            dataJson.put("store", "TVEL117N01");
            //收银机编号
            dataJson.put("tillId", "01");
            dataJson.put("time", nowDate);
            //订单总金额
            dataJson.put("totalAmt", money);
            //销售：SALE 退货：ONLINEREFUND
            dataJson.put("type", "SALE");
            //dataJson.put("type", "ONLINEREFUND");
            //来源 01 店铺 02数据采集盒子
            dataJson.put("source", "01");
            //合作伙伴身份标识
            String Partner_ID = "70000006";
            //调用的API版本号
            String Api_Version = "1.0.0";
            //被调用API的应用编码
            String App_Sub_ID = "10000133334IX";
            //API调用的API编码
            String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
            //API调用方授权令牌
            String App_Token = "b6f115582d3343f39cc18a8232f338b9";
            //被调用API的应用编码
            String App_Pub_ID = "10000133301US";
            //合作伙伴系统编码
            String Sys_ID = "100001333";

            //拼接待签名字符串
            String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                    dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
            //生成签名获取sign的值
            String sign = Md5Util.md5(strs);
            System.out.println("strs:" + strs);
            System.out.println("sign:" + sign);

            JSONObject contentJson = new JSONObject();
            contentJson.put("Partner_ID", Partner_ID);
            contentJson.put("Api_Version", Api_Version);
            contentJson.put("App_Sub_ID", App_Sub_ID);
            //响应格式,默认为json格式，可选值：xml或json
            contentJson.put("Format", "json");
            //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
            contentJson.put("Time_Stamp", now);
            contentJson.put("Api_ID", Api_ID);
            contentJson.put("App_Token", App_Token);
            contentJson.put("App_Pub_ID", App_Pub_ID);
            //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
            contentJson.put("Sign_Method", "md5");
            //服务请求的签名字符串
            contentJson.put("Sign", sign);
            contentJson.put("Sys_ID", Sys_ID);
            JSONObject jsons = new JSONObject();
            jsons.put("REQUEST_DATA", dataJson);
            jsons.put("HRT_ATTRS", contentJson);

            JSONObject json = new JSONObject();
            json.put("REQUEST", jsons);
            System.out.println("REQUEST_DATA:" + dataJson);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            // String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
            String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
            String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
            if (errcode.equals("0000")) {
                System.out.println("南湖销售数据更新成功！");
                logger.info("===南湖销售数据更新成功！");
            } else {
                System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
                logger.info("错误码：" + errcode + "错误信息:" + errmsg);
            }
        } catch (Exception e) {
            logger.error("更新南湖销售数据 出现异常", e);
            e.printStackTrace();
        }
    }

    @Test
    public void yongyouYfd() {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code");
        //系统编码
        headers.add("system", "001");
        //用户
        headers.add("usercode", "15253172037");
        //密码 md5加密32位小写
        headers.add("password", "82a21ba38d518b2ee8dc3904412ef3e0");

        JSONObject jsons = new JSONObject();
        HttpEntity<String> formEntitys = new HttpEntity<String>(jsons.toString(), headers);
        //获取公司编码
        String urls = "http://124.70.28.147:8089/u8cloud/api/uapbd/bdcorp/query";
        //String  result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
        //String results = restTemplate.postForEntity(urls, formEntitys, String.class).getBody();
        //System.out.println("result:" + results);
        Yfd yfds = restTemplate.postForEntity(urls, formEntitys, Yfd.class).getBody();
        JSONObject resultObjects = JSON.parseObject(yfds.getData());
        JSONArray jsonArrays = resultObjects.getJSONArray("datas");
        List<String> gsbmList = new ArrayList<>();
        if (ToolUtil.isNotEmpty(jsonArrays)) {
            for (int i = 0; i < jsonArrays.size(); i++) {
                JSONObject jsonObject = jsonArrays.getJSONObject(i);
                String unitcode = jsonObject.getOrDefault("unitcode", "").toString();
                gsbmList.add(unitcode);
            }
        }
        if (gsbmList.size() > 0) {
            for (String gsbm : gsbmList) {
                JSONObject json = new JSONObject();
                json.put("dwbm", gsbm);
                json.put("djrq_from", "2021-05-25");
                json.put("djrq_to", "2021-05-25");
                headers.add("Accept", MediaType.APPLICATION_JSON.toString());
                HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
                //获取用友应付单
                String url = "http://124.70.28.147:8089/u8cloud/api/arap/yf/pagequery";
                //String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
                //System.out.println("result:" + result);
                Yfd yfd = restTemplate.postForEntity(url, formEntity, Yfd.class).getBody();
                //System.out.println("yfd:" + yfd.getData());
                JSONObject resultObject = JSON.parseObject(yfd.getData());
                JSONArray jsonArray = resultObject.getJSONArray("datas");
                //System.out.println("size:" + jsonArray.size());
                JSONObject jsonObject;
                if (jsonArray != null) {
                    for (int i = 0; i < jsonArray.size(); i++) {
                        BtyYfd btyYfd = new BtyYfd();
                        jsonObject = jsonArray.getJSONObject(i);
                        ParentvoBean parentvo = jsonObject.getObject("parentvo", ParentvoBean.class);
                        List<ChildrenvoBean> childrenvo = JSON.parseArray(jsonObject.get("childrenvo").toString(), ChildrenvoBean.class);
                        btyYfd.setId(UUIDUtils.getId());
                        btyYfd.setVouchid(parentvo.getVouchid());
                        btyYfd.setDwbm(parentvo.getDwbm());
                        btyYfd.setDwbmCode(parentvo.getDwbm_code());
                        btyYfd.setDwbmName(parentvo.getDwbm_name());
                        btyYfd.setDjbh(parentvo.getDjbh());
                        btyYfd.setDjrq(parentvo.getDjrq());
                        btyYfd.setLrr(parentvo.getLrr());
                        btyYfd.setLrrCode(parentvo.getLrr_code());
                        btyYfd.setLrrName(parentvo.getLrr_name());
                        btyYfd.setDjzt(parentvo.getDjzt());
                        btyYfd.setShrCode(parentvo.getShr_code());
                        btyYfd.setShrName(parentvo.getShr_name());
                        btyYfd.setShrq(parentvo.getShrq());
                        btyYfd.setZdrq(parentvo.getZdrq());
                        btyYfd.setYbje(new BigDecimal(parentvo.getYbje()));
                        btyYfd.setBbje(new BigDecimal(parentvo.getBbje()));
                        btyYfd.setDjkjnd(parentvo.getDjkjnd());
                        btyYfd.setDjkjqj(parentvo.getDjkjqj());
                        btyYfd.setDjdl(parentvo.getDjdl());
                        btyYfd.setZzzt(parentvo.getZzzt());
                        btyYfd.setSpzt(parentvo.getSpzt());
                        btyYfd.setYwbm(parentvo.getYwbm());
                        btyYfd.setYwbmCode(parentvo.getYwbm_code());
                        btyYfd.setYwbmName(parentvo.getYwbm_name());
                        btyYfd.setXslxbm(parentvo.getXslxbm());
                        btyYfd.setXslxbmCode(parentvo.getXslxbm_code());
                        btyYfd.setXslxbmName(parentvo.getXslxbm_name());
                        btyYfd.setDjlxbm(parentvo.getDjlxbm());
                        btyYfd.setPjJsfs(parentvo.getPj_jsfs());
                        btyYfd.setPjJsfsCode(parentvo.getPj_jsfs_code());
                        btyYfd.setPjJsfsName(parentvo.getPj_jsfs_name());
                        btyYfd.setDeptid(childrenvo.get(0).getDeptid());
                        btyYfd.setDeptidCode(childrenvo.get(0).getDeptid_code());
                        btyYfd.setDeptidName(childrenvo.get(0).getDeptid_name());
                        btyYfd.setFbOid(childrenvo.get(0).getFb_oid());
                        btyYfd.setZyx2(childrenvo.get(0).getZyx2());
                        btyYfd.setHbbm(childrenvo.get(0).getHbbm());
                        btyYfd.setHbbmCode(childrenvo.get(0).getHbbm_code());
                        btyYfd.setHbbmName(childrenvo.get(0).getHbbm_name());
                        btyYfd.setWldx(childrenvo.get(0).getWldx());
                        btyYfd.setBzbm(childrenvo.get(0).getBzbm());
                        btyYfd.setBzbmCode(childrenvo.get(0).getBzbm_code());
                        btyYfd.setBzbmName(childrenvo.get(0).getBzbm_name());
                        btyYfd.setJfybwsje(new BigDecimal(childrenvo.get(0).getJfybwsje()));
                        btyYfd.setKslb(childrenvo.get(0).getKslb());
                        btyYfdService.save(btyYfd);
                    }
                }
            }
        }

    }

    @Test
    public void yongyouFkd() {

        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
        headers.add("system", "001"); // 系统编码
        headers.add("usercode", "15253172037"); // 用户
        headers.add("password", "82a21ba38d518b2ee8dc3904412ef3e0");
        for (int j = 301; j < 316; j++) {
            JSONObject json = new JSONObject();
            json.put("dwbm", j + "");
            json.put("djrq_from", "2021-05-25");
            json.put("djrq_to", "2021-05-25");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            String url = "http://124.70.28.147:8089/u8cloud/api/arap/fk/pagequery";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            Yfd yfd = restTemplate.postForEntity(url, formEntity, Yfd.class).getBody();
            System.out.println("yfd:" + yfd.getData());
            JSONObject resultObject = JSON.parseObject(yfd.getData());
            JSONArray jsonArray = resultObject.getJSONArray("datas");
//        System.out.println("size:" + jsonArray.size());
            JSONObject jsonObject;
            if (jsonArray != null) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    BtyYfd btyYfd = new BtyYfd();
                    jsonObject = jsonArray.getJSONObject(i);
                    ParentvoBean parentvo = jsonObject.getObject("parentvo", ParentvoBean.class);
                    List<ChildrenvoBean> childrenvo = JSON.parseArray(jsonObject.get("childrenvo").toString(), ChildrenvoBean.class);
                    btyYfd.setId(UUIDUtils.getId());
                    btyYfd.setVouchid(parentvo.getVouchid());
                    btyYfd.setDwbm(parentvo.getDwbm());
                    btyYfd.setDwbmCode(parentvo.getDwbm_code());
                    btyYfd.setDwbmName(parentvo.getDwbm_name());
                    btyYfd.setDjbh(parentvo.getDjbh());
                    btyYfd.setDjrq(parentvo.getDjrq());
                    btyYfd.setLrr(parentvo.getLrr());
                    btyYfd.setLrrCode(parentvo.getLrr_code());
                    btyYfd.setLrrName(parentvo.getLrr_name());
                    btyYfd.setDjzt(parentvo.getDjzt());
                    btyYfd.setShrCode(parentvo.getShr_code());
                    btyYfd.setShrName(parentvo.getShr_name());
                    btyYfd.setShrq(parentvo.getShrq());
                    btyYfd.setZdrq(parentvo.getZdrq());
                    btyYfd.setYbje(new BigDecimal(parentvo.getYbje()));
                    btyYfd.setBbje(new BigDecimal(parentvo.getBbje()));
                    btyYfd.setDjkjnd(parentvo.getDjkjnd());
                    btyYfd.setDjkjqj(parentvo.getDjkjqj());
                    btyYfd.setDjdl(parentvo.getDjdl());
                    btyYfd.setZzzt(parentvo.getZzzt());
                    btyYfd.setSpzt(parentvo.getSpzt());
                    btyYfd.setYwbm(parentvo.getYwbm());
                    btyYfd.setYwbmCode(parentvo.getYwbm_code());
                    btyYfd.setYwbmName(parentvo.getYwbm_name());
                    btyYfd.setXslxbm(parentvo.getXslxbm());
                    btyYfd.setXslxbmCode(parentvo.getXslxbm_code());
                    btyYfd.setXslxbmName(parentvo.getXslxbm_name());
                    btyYfd.setDjlxbm(parentvo.getDjlxbm());
                    btyYfd.setPjJsfs(parentvo.getPj_jsfs());
                    btyYfd.setPjJsfsCode(parentvo.getPj_jsfs_code());
                    btyYfd.setPjJsfsName(parentvo.getPj_jsfs_name());
                    btyYfd.setDeptid(childrenvo.get(0).getDeptid());
                    btyYfd.setDeptidCode(childrenvo.get(0).getDeptid_code());
                    btyYfd.setDeptidName(childrenvo.get(0).getDeptid_name());
                    btyYfd.setFbOid(childrenvo.get(0).getFb_oid());
                    btyYfd.setZyx2(childrenvo.get(0).getZyx2());
                    btyYfd.setHbbm(childrenvo.get(0).getHbbm());
                    btyYfd.setHbbmCode(childrenvo.get(0).getHbbm_code());
                    btyYfd.setHbbmName(childrenvo.get(0).getHbbm_name());
                    btyYfd.setWldx(childrenvo.get(0).getWldx());
                    btyYfd.setBzbm(childrenvo.get(0).getBzbm());
                    btyYfd.setBzbmCode(childrenvo.get(0).getBzbm_code());
                    btyYfd.setBzbmName(childrenvo.get(0).getBzbm_name());
                    btyYfd.setJfybwsje(new BigDecimal(childrenvo.get(0).getJfybwsje()));
                    btyYfd.setKslb("fkd");
                    btyYfdService.save(btyYfd);
                }
            }
        }


    }

    @Test
    public void readExcels() throws Exception {
        //读取excel中的数据存到bank_jhsk表中
        SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");//设置日期格式
        //String date = df.format(new Date());
        String date = "20210521";
        File file = new File("G:/CCB_EBSClient_B2C4FileCert_V5.9.3_Build20190827/download/105003958129374/SHOP.105003958129374." + date + " (Group Summary Statement).xls");
        InputStream is = new FileInputStream(file.getAbsoluteFile());
        Workbook wb = new HSSFWorkbook(is);
        Sheet sheet = wb.getSheetAt(0);
        int lastRowNum = sheet.getLastRowNum();
        for (int r = 27; r <= lastRowNum; r++) {
            Row row = sheet.getRow(r);
            if (row == null) {
                continue;
            }
            for (int m = 1; m < 28; m++) {
                Cell cell = row.getCell(m);
                if (ToolUtil.isNotEmpty(cell)) {
                    cell.setCellType(CellType.STRING);
                }
            }
            //场景标识
            String cjbs = row.getCell(7) == null ? "" : row.getCell(7).getStringCellValue();
            //终端号
            String zdh = row.getCell(5) == null ? "" : row.getCell(5).getStringCellValue();
            //交易日期
            String jyrq = row.getCell(12) == null ? "" : row.getCell(12).getStringCellValue();
            //交易时间
            String jysj = row.getCell(13) == null ? "" : row.getCell(13).getStringCellValue();
            //交易金额16列
            //String jyje = row.getCell(16) == null ? "" : row.getCell(16).getStringCellValue();
            //划账金额21列
            String jyje = row.getCell(21) == null ? "" : row.getCell(21).getStringCellValue();
            //支付卡号
            String zfkh = row.getCell(25) == null ? "" : row.getCell(25).getStringCellValue();
            //订单编号
            String ddbh = row.getCell(26) == null ? "" : row.getCell(26).getStringCellValue();
            //商户柜台代码
            String shgtdm = row.getCell(27) == null ? "" : row.getCell(27).getStringCellValue();
            //持卡人姓名29列
            BankTest bankTest = new BankTest();
            if (jyje.contains(".")) {
                if (ToolUtil.isNotEmpty(ddbh)) {
                    bankTest.setId(UUIDUtils.getId());
                    bankTest.setDdbh(ddbh);
                    bankTest.setZdh(zdh);
                    bankTest.setJyrq(jyrq);
                    bankTest.setJysj(jysj);
                    bankTest.setZfkh(zfkh);
                    bankTest.setJyje(jyje);
                    bankTest.setCjbs(cjbs);
                    bankTest.setShgtdm(shgtdm);
                    bankTestService.save(bankTest);
                }
            }
        }
    }

    /**
     * 定时保存会员差异数据 每天下午10点30分执行
     */
    @Test
    public void hycy() {
            try {
                logger.info("====定时保存会员差异数据开始====");
                String yesterDayDate = DateUtil.getYesterDayDate();
                //String yesterDayDate = "2021-12-18";
                BtyHykParam param = new BtyHykParam();
                param.setYyr(yesterDayDate);
                List<BtyHykResult> list3 = hykService.listMdxfbj(param);
                DecimalFormat df = new DecimalFormat("#.00");
                if (list3.size() > 0) {
                    for (BtyHykResult btyHykResult : list3) {
                        BigDecimal xj = BigDecimal.ZERO;
                        BigDecimal zfb = BigDecimal.ZERO;
                        BigDecimal wx = BigDecimal.ZERO;
                        BigDecimal jhsk = BigDecimal.ZERO;
                        BigDecimal dpmd = BigDecimal.ZERO;
                        //嘉联支付
                        BigDecimal jlzf = BigDecimal.ZERO;
                        //商场收款
                        BigDecimal scsk = BigDecimal.ZERO;
                        String dm = btyHykResult.getDm();
                        param.setDm(dm);
                        List<BtyHykResult> list2 = hykService.listMdByDm(param);
                        for (BtyHykResult hykResult : list2) {
                            String czlxmc = hykResult.getCzlxmc();
                            if (czlxmc.equals("现金")) {
                                xj = hykResult.getCzje();
                            } else if (czlxmc.equals("支付宝")) {
                                zfb = hykResult.getCzje();
                            } else if (czlxmc.equals("微信")) {
                                wx = hykResult.getCzje();
                            } else if (czlxmc.equals("建行收款")) {
                                jhsk = hykResult.getCzje();
                            } else if (czlxmc.equals("点评买单")) {
                                dpmd = hykResult.getCzje();
                            } else if (czlxmc.equals("嘉联支付")) {
                                jlzf = hykResult.getCzje();
                            } else if (czlxmc.equals("商场收款")) {
                                scsk = hykResult.getCzje();
                            }
                        }
                        //获取yybb中的现金差异
                        BigDecimal xjcy = BigDecimal.ZERO;
                        BigDecimal zfbcy = BigDecimal.ZERO;
                        BigDecimal wxcy = BigDecimal.ZERO;
                        BigDecimal mdcy = BigDecimal.ZERO;
                        BigDecimal jhcy = BigDecimal.ZERO;

                        BigDecimal hycy1 = BigDecimal.ZERO;
                        BigDecimal hycy2 = BigDecimal.ZERO;
                        BigDecimal hycy3 = BigDecimal.ZERO;
                        BigDecimal hycy4 = BigDecimal.ZERO;
                        BigDecimal hycy5 = BigDecimal.ZERO;

                        jhsk = jhsk.add(jlzf);
                        //if (dm.equals("半天妖江苏常州九洲新世界店")) {
                        Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                        if (ToolUtil.isNotEmpty(yybb)) {
                            xjcy = yybb.getXjce();
                            zfbcy = yybb.getZfbcy();
                            wxcy = yybb.getWxcy();
                            mdcy = yybb.getMtcy();
                            jhcy = yybb.getYhkcy();
                            String xjbz = yybb.getXjbz();
                            String wxbz = yybb.getWxbz();
                            String yhkbz = yybb.getYhkbz();

                            int xjFlag = xj.compareTo(BigDecimal.ZERO);
                            int wxFlag = wx.compareTo(BigDecimal.ZERO);
                            int jhskFlag = jhsk.compareTo(BigDecimal.ZERO);
                            if (xjFlag == 1) {
                                String xjs = df.format(xj);
                                if (ToolUtil.isNotEmpty(xjbz)) {
                                    xjbz = xjbz + "," + xjs;
                                    yybb.setXjbz(xjbz);
                                } else {
                                    yybb.setXjbz(xjs);
                                }
                                yybbService.updateById(yybb);
                            }
                            if (wxFlag == 1) {
                                String wxs = df.format(wx);
                                if (ToolUtil.isNotEmpty(wxbz)) {
                                    wxbz = wxbz + "," + wxs;
                                    yybb.setWxbz(wxbz);
                                } else {
                                    yybb.setWxbz(wxs);
                                }
                                yybbService.updateById(yybb);
                            }
                            if (jhskFlag == 1) {
                                String jhsks = df.format(jhsk);
                                if (ToolUtil.isNotEmpty(yhkbz)) {
                                    yhkbz = yhkbz + "," + jhsks;
                                    yybb.setYhkbz(yhkbz);
                                } else {
                                    yybb.setYhkbz(jhsks);
                                }
                                yybbService.updateById(yybb);
                            }
                        }
                        BtyHycy hycy = new BtyHycy();
                        hycy.setMc(dm);
                        hycy.setHyxj(xj);
                        hycy.setHyzfb(zfb);
                        hycy.setHywx(wx);
                        hycy.setHymd(dpmd);
                        hycy.setMdzy(mdcy);
                        hycy.setScsk(scsk);

                        hycy.setHyjh(jhsk);
                        hycy.setXjcy(xjcy);
                        hycy.setZfbcy(zfbcy);
                        hycy.setWxcy(wxcy);
                        hycy.setJhcy(jhcy);
                        hycy.setRq(yesterDayDate);
                        hycy1 = xjcy.subtract(xj);
                        hycy2 = zfbcy.subtract(zfb);
                        hycy3 = wxcy.subtract(wx);
                        hycy4 = mdcy.subtract(dpmd);
                        hycy5 = jhcy.subtract(jhsk);
                        hycy.setHycy(hycy1);
                        hycy.setHycy1(hycy2);
                        hycy.setHycy2(hycy3);
                        hycy.setHycy3(hycy4);
                        hycy.setHycy4(hycy5);
                        hycyService.save(hycy);
                     //}
                    }
                }
                logger.info("====定时保存会员差异数据结束====");
            } catch (Exception e) {
                String err = e.getMessage();
                String data = "定时保存会员差异数据出现异常！";
                JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
                String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                logger.info("====定时保存会员差异数据出现异常====" + e);
                e.printStackTrace();
            }
    }


    @Test
    public void salesDataQd() {
        try {
            logger.info("===更新青岛悦荟广场店数据开始...");
            String yesterday = DateUtil.getYesterDay4Oclock();
            String today = DateUtil.getToday4Oclock();
            Timestamp yesterdayTime = Timestamp.valueOf(yesterday);
            Timestamp todayTime = Timestamp.valueOf(today);
            //获取更新青岛悦荟广场店销售额
            //String money = bizService.lastMoneyByShopCode("403", yesterdayTime, todayTime);
            String money = "11703.15";
//            if (ToolUtil.isEmpty(money)) {
//                money = "0";
//            }
            logger.info("青岛悦荟广场店销售额：" + money);
            //构造请求报文
            StringBuilder soap = new StringBuilder();
            soap.append(" <soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>");
            //<--Header标头信息start-->
            soap.append(" <soap:Body>");
            soap.append(" <postsalescreate xmlns='http://tempurl.org'>");
            soap.append(" <astr_request>");
            soap.append(" <header>");
            //用户名
            soap.append(" <username>CRMINT</username>");
            //密码
            soap.append(" <password>010201</password>");
            //消息类型
            soap.append(" <messagetype>SALESDATA</messagetype>");
            //消息id
            soap.append(" <messageid>332</messageid>");
            //版本编号
            soap.append(" <version>V332M</version>");
            soap.append(" </header>");
            //<--Header标头信息end-->
            //<--SalesTotal:销售单主表start-->
            soap.append("  <salestotal>");
            //交易日期
            //SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
//                String number = DateUtil.getYesterDayTime();
//                String date = number.substring(0, 8);
//                String time = number.substring(number.length() - 6);

            String number = "20220223233045";
            String date = "20220223";
            String time = "233045";
            //String money="0";
            soap.append(" <txdate_yyyymmdd>" + date + "</txdate_yyyymmdd>");
            //交易时间
            soap.append(" <txtime_hhmmss>" + time + "</txtime_hhmmss>");
            //商城编号
            // soap.append(" <mallid>5012</mallid>");
            //店铺号
            soap.append(" <storecode>tqd00320</storecode>");
            //收银机号
            soap.append(" <tillid>01</tillid>");
            //销售单号
            soap.append(" <txdocno>" + number + "</txdocno>");
            //收银员编号
            soap.append(" <cashier>001</cashier>");
            //销售员
            soap.append(" <salesman></salesman>");
            //数量
            soap.append(" </salestotal>");
            //<--SalesTotal:销售单主表end-->
            //<--SalesI销售单货品明细表start-->
            soap.append(" <salesitems>");
            soap.append(" <salesitem>");
            //商品编号
            soap.append(" <itemcode>tqd0032001</itemcode>");
            //数量
            soap.append(" <qty>1</qty>");
            //净金额
            soap.append(" <netamount>" + money + "</netamount>");
            soap.append(" </salesitem>");
            soap.append(" </salesitems>");
            //<--SalesI销售单货品明细表end-->

            //<!--销售单付款明细表start-->
            soap.append(" <salestenders>");
            soap.append(" <salestender>");
            //付款代码
            soap.append(" <tendercode>CH</tendercode>");
            //付款金额
            soap.append(" <payamount>" + money + "</payamount>");
            //本位币金额
            soap.append(" <baseamount>" + money + "</baseamount>");
            soap.append(" </salestender>");
            soap.append(" </salestenders>");
            //<!--SalesTender销售单付款明细表end-->

            soap.append(" </astr_request>");
            soap.append(" </postsalescreate>");
            soap.append(" </soap:Body>");
            soap.append(" </soap:Envelope>");
            String requestSoap = soap.toString();
            System.out.println("requestSoap:" + requestSoap);
            //服务地址(将url替换成自己项目的地址)
            String serviceAddress = "http://123.234.71.6:8099/ChiaTai/salestrans.asmx?WSDL";
            String charSet = "utf-8";
            String contentType = "text/xml; charset=utf-8";
            //String contentType="application/soap+xml; charset=utf-8";
            //第一步：调用方法getResponseSoap。返回响应报文和状态码
            Map<String, Object> responseSoapMap = SoapUtil.responseSoap(requestSoap, serviceAddress, charSet, contentType);
            Integer statusCode = (Integer) responseSoapMap.get("statusCode");
            if (statusCode == 200) {
                String responseSoap = (String) responseSoapMap.get("responseSoap");
                logger.info("===返回的报文为===" + responseSoap);
                // String targetNodeName="ESB_RETURN_CODE";
                String targetNodeName = "responsecode";
                //第二步：调用strXmlToDocument方法。将字符串类型的XML的响应报文 转化成Document结构文档
                Document doc = Jdom2XMLUtil.strXmlToDocument(responseSoap);
                //第三步：调用getValueByElementName方法。递归获得目标节点的值
                String result = Jdom2XMLUtil.getValueByElementName(doc, targetNodeName);
                if (ToolUtil.isNotEmpty(result) && result.equals("0")) {
                    System.out.println(result);
                    logger.info("===青岛悦荟广场店result===" + result);
                    logger.info("===青岛悦荟广场店销售数据更新完成===");
                } else {
                    String data = "更新青岛悦荟广场店销售数据出现异常！result=" + result;
                    JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, result, DateUtil.getNow(), data);
                    String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                    weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                    System.out.println("没有此节点或者没有值!");
                }
            } else {
                System.out.println("请求失败!");
            }
        } catch (Exception e) {
            String err = e.getMessage();
            String data = "更新青岛悦荟广场店销售数据出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.error("更新青岛悦荟广场店销售数据 出现异常", e);
            e.printStackTrace();
        }

    }

    @Test
    public void sk() {
        //获取bank_jhsk表中的数据,更新建行收款金额到yybb中
        String yesterdayDate = DateUtil.getYesterDayDate();
        BankTestParam param = new BankTestParam();
        param.setJyrq(yesterdayDate);
        List<BankTestResult> list = bankTestService.listMdye(param);
        for (BankTestResult bankTestResult : list) {
            String dm = bankTestResult.getDm();
            BigDecimal je = bankTestResult.getJyje();
            BigDecimal sxf = bankTestResult.getYhksxf();
            System.out.println("sxf:" + sxf);
            Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterdayDate));
            if (ToolUtil.isNotEmpty(yybb)) {
                yybb.setYhksj(je);
                yybb.setYhksxf(sxf);
                yybbService.updateById(yybb);
            }

        }
        logger.info("====更新建行收款结束====");
    }

    @Test
    public void salesDataYt() {
        try {
            logger.info("===更新烟台万象汇数据开始...");
            String today = DateUtil.getToday4Oclock();
            String nextday = DateUtil.getNextDay4Oclock();
            Timestamp todayTime = Timestamp.valueOf(today);
            Timestamp nextdayTime = Timestamp.valueOf(nextday);
            //获取烟台莱山万象汇店销售额
            String money = bizService.lastMoneyByShopCode("831", todayTime, nextdayTime);
            if (ToolUtil.isEmpty(money)) {
                money = "0";
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            String now = sdf.format(new Date());
            String nowDate = DateUtil.getStampNow();
            logger.info("烟台万象汇销售额：" + money);
            String str[] = {};
            Map map = new HashMap();
            map.put("cardBank", "");
            map.put("cardNumber", "");
            map.put("discountAmt", 0);
            map.put("payAmt", money);
            map.put("paymentMethod", "CH");
            map.put("time", nowDate);
            map.put("value", money);
            List<Map<String, Object>> payList = new ArrayList<>();
            payList.add(map);

            RestTemplate restTemplate = new RestTemplate();
            JSONObject dataJson = new JSONObject();
            //收银员编号
            //dataJson.put("cashierId", "20095ntgl203n0101");
            dataJson.put("cashierId", "20095ntgl332n0101");
            //店铺验证密钥
            dataJson.put("checkCode", "p88888888");
            //备注
            dataJson.put("comments", "comments");
            dataJson.put("itemList", str);
            //商场编号
            dataJson.put("mall", "20095");
            dataJson.put("mobile", "");
            //订单号
            dataJson.put("orderId", nowDate);
            dataJson.put("payList", payList);
            dataJson.put("refOrderId", "refOrderId");
            //店铺编号
            //dataJson.put("store", "NTGL203N01");
            dataJson.put("store", "NTGL332N01");
            //收银机编号
            dataJson.put("tillId", "01");
            dataJson.put("time", nowDate);
            //订单总金额
            dataJson.put("totalAmt", money);
            dataJson.put("type", "SALE");
            //dataJson.put("type", "ONLINEREFUND");
            //来源 01 店铺 02数据采集盒子
            dataJson.put("source", "01");
            //合作伙伴身份标识
            //String Partner_ID = "70000006";
            String Partner_ID = "70000029";
            //调用的API版本号
            // String Api_Version = "1.0.0";
            String Api_Version = "1.0.1";
            //被调用API的应用编码
            //String App_Sub_ID = "10000133334PY";
            String App_Sub_ID = "10000187223AY";
            //API调用的API编码
            String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
            //API调用方授权令牌
            //String App_Token = "c861e8a4be0f41b182abdb55b986444a";
            String App_Token = "c11814f66b9144688b499e5e54f77972";
            //被调用API的应用编码
            //String App_Pub_ID = "10000133301US";
            String App_Pub_ID = "10000187223RL";
            //合作伙伴系统编码
            //String Sys_ID = "100001333";
            String Sys_ID = "100001872";

            //拼接待签名字符串
            String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                    dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
            //生成签名获取sign的值
            String sign = Md5Util.md5(strs);
            System.out.println("strs:" + strs);
            System.out.println("sign:" + sign);

            JSONObject contentJson = new JSONObject();
            contentJson.put("Partner_ID", Partner_ID);
            contentJson.put("Api_Version", Api_Version);
            contentJson.put("App_Sub_ID", App_Sub_ID);
            //响应格式,默认为json格式，可选值：xml或json
            contentJson.put("Format", "json");
            //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
            contentJson.put("Time_Stamp", now);
            contentJson.put("Api_ID", Api_ID);
            contentJson.put("App_Token", App_Token);
            contentJson.put("App_Pub_ID", App_Pub_ID);
            //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
            contentJson.put("Sign_Method", "md5");
            //服务请求的签名字符串
            contentJson.put("Sign", sign);
            contentJson.put("Sys_ID", Sys_ID);
            JSONObject jsons = new JSONObject();
            jsons.put("REQUEST_DATA", dataJson);
            jsons.put("HRT_ATTRS", contentJson);

            JSONObject json = new JSONObject();
            json.put("REQUEST", jsons);
            System.out.println("REQUEST_DATA:" + dataJson);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            //正式环境
            String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
            //测试环境
            //String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
            String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
            if (errcode.equals("0000")) {
                System.out.println("烟台万象汇销售数据更新成功！");
                logger.info("===烟台万象汇销售数据更新成功！");
            } else {
                System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
                logger.info("错误码：" + errcode + "错误信息:" + errmsg);
            }
        } catch (Exception e) {
            logger.error("更新烟台万象汇销售数据 出现异常", e);
            e.printStackTrace();
        }
    }

    @Test
    public void test111() {
        //导入成功之后更新饿了么结算金额到yybb中
        BtyElmParam param = new BtyElmParam();
//            String month= DateUtil.getCurrentMonth();
//            param.setMonth(month);
        List<BtyElmResult> list = elmMapper.elmList(param);
        for (BtyElmResult btyElmResult : list) {
            String dm = btyElmResult.getDm();
            String yyr = btyElmResult.getZdrq();
            BigDecimal jsje = btyElmResult.getJsje();
            Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yyr));
            if (ToolUtil.isNotEmpty(yybb)) {
//                   BigDecimal elmsj=yybb.getElmsj()==null?BigDecimal.ZERO:yybb.getElmsj();
//                   elmsj=elmsj.add(jsje);
                yybb.setElmsj(jsje);
                yybbService.updateById(yybb);
            }
        }
    }
    @Test
    public void ekbTest() {
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        JSONObject json = new JSONObject();
        json.put("appKey", "32de31e8-9a31-4cf9-a69b-74ddee365cf2");
        json.put("appSecurity", "149b3780-99bf-4431-976e-27d80896452f");
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
        String url = "https://dd2.ekuaibao.com/api/openapi/v1/auth/getAccessToken";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
        JsonParser jp = new JsonParser();
        //将json字符串转化成json对象
        JsonObject jo = jp.parse(result).getAsJsonObject();
        //获取accessToken
        String accessToken = jo.get("value").getAsJsonObject().get("accessToken").getAsString();
        String ekbId = "ID_3q2QMgOWyF0";//  ID_3lnkBTH9jP0
        String url1 = "https://dd2.ekuaibao.com/api/openapi/v1/flowDetails?flowId=" + ekbId + "&accessToken=" + accessToken;
        Bill bill = restTemplate.getForEntity(url1, Bill.class).getBody();
        String result1 = restTemplate.getForEntity(url1,String.class).getBody();
        System.out.println("result1:"+result1);
        //费用分摊部门
        String bms = "";
        //费用分摊比例
        String ftbl = "";
        //费用分摊金额
        String ftjes = "";
        //获取易快报报销单费用分摊的相关信息
        List<Bill.ValueBean.FormBean.Details> list = bill.getValue().getForm().getDetails();
        System.out.println("list:"+list);
        for (Bill.ValueBean.FormBean.Details details : list) {
            if (ToolUtil.isNotEmpty(details.getFeeTypeForm().getApportions())) {
                List<Bill.ValueBean.FormBean.Details.FeeTypeFormBean.ApportionsBean> apportionsBeanList = details.getFeeTypeForm().getApportions();
                for (Bill.ValueBean.FormBean.Details.FeeTypeFormBean.ApportionsBean apportionsBean : apportionsBeanList) {
                    String apportionPercent = apportionsBean.getApportionForm().getApportionPercent();
                    ftbl = ftbl + apportionPercent + ",";
                    String ftje = apportionsBean.getApportionForm().getApportionMoney().getStandard();
                    ftjes = ftjes + ftje + ",";
                    String ftbmId = apportionsBean.getApportionForm().getExpenseDepartment();
                    //通过部门id获取部门名称
                    String url2 = "https://dd2.ekuaibao.com/api/openapi/v1/departments/$" + ftbmId + "?departmentBy=id&accessToken=" + accessToken;
                    String result2 = restTemplate.getForEntity(url2, String.class).getBody();
                    //将json字符串转化成json对象
                    JsonObject jo1 = jp.parse(result2).getAsJsonObject();
                    //获取部门名称
                    String bm1 = jo1.get("value").getAsJsonObject().get("name").getAsString();
                    if (bm1.equals("半天妖潍坊高密金孚隆中心店")) {
                        bm1 = "潍坊高密金孚隆购物广场店";
                    }
                    if (bm1.equals("半天妖福州万象九宜城店")) {
                        bm1 = "半天妖福建福州万象九宜城店";
                    }
                    if (bm1.equals("半天妖青岛胶州利群购物广场店")) {
                        bm1 = "半天妖山东青岛胶州利群店";
                    }
                    if (bm1.equals("上饶万达店")) {
                        bm1 = "上饶信州万达店";
                    }
                    if (bm1.equals("半天妖江苏镇江吾悦店")) {
                        bm1 = "半天妖镇江吾悦店";
                    }
                    if (bm1.equals("半天妖北京大兴宾馆店")) {
                        bm1 = "半天妖北京大兴店";
                    }
                    if (bm1.equals("新乡新玛特")) {
                        bm1 = "新乡市大商新玛特店";
                    }
                    if (bm1.equals("半天妖滕州人和店")) {
                        bm1 = "半天妖滕州人和广场店";
                    }
                    if (bm1.equals("威海荣成九龙城店")) {
                        bm1 = "半天妖威海荣成市九龙城店";
                    }
                    bms = bms + bm1 + ",";
                    //System.out.println("分摊部门："+bm1+"分摊比例:"+apportionPercent+  "分摊金额："+ftje);
                    BtyEkb ftEkb = new BtyEkb();
                    ftEkb.setId(UUIDUtils.getId());
                    ftEkb.setBm(bm1);
                    ftEkb.setSumAmount(new BigDecimal(ftje));
                    //ftEkb.setEkbId(bxd.getFlowId());
                    //ftEkb.setNodeId(bxd.getNodeId());
                    BtyEkb ekb1 = ekbService.getOne(new QueryWrapper<BtyEkb>().eq("ekb_id", ekbId));
                    if (ToolUtil.isNotEmpty(ekb1)) {
                        ftEkb.setTitle(ekb1.getTitle());
                        ftEkb.setBxr(ekb1.getBxr());
                        ftEkb.setFkr(ekb1.getFkr());
                        ftEkb.setCode(ekb1.getCode());
                        ftEkb.setFtid(ekb1.getId());
                        ftEkb.setBank(ekb1.getBank());
                        ftEkb.setYhk(ekb1.getYhk());
                        ftEkb.setZhmc(ekb1.getZhmc());
                        ftEkb.setHh(ekb1.getHh());
                        ftEkb.setRemark(ekb1.getRemark());
                    }
                    ftEkb.setSumAmount(new BigDecimal(ftje));
                    ftEkb.setBm(bm1);
                    ftEkb.setFtbz(0);
                    ftEkb.setYyr(DateUtil.getNowDate());
                    ekbService.save(ftEkb);
                }
            }
        }
        if (ftbl.length() > 0) {
            ftbl = ftbl.substring(0, ftbl.length() - 1);
        }
        if (ftjes.length() > 0) {
            ftjes = ftjes.substring(0, ftjes.length() - 1);
        }
        if (bms.length() > 0) {
            bms = bms.substring(0, bms.length() - 1);
        }
        //更新费用承担部门，分摊比例，分摊费用到易快报表中
        BtyEkb ekb1 = ekbService.getOne(new QueryWrapper<BtyEkb>().eq("ekb_id", ekbId));
        if (ToolUtil.isNotEmpty(ekb1) && ToolUtil.isNotEmpty(bms)) {
            if (ToolUtil.isNotEmpty(bms)) {
                ekb1.setBms(bms);
            }
            if (ToolUtil.isNotEmpty(ftbl)) {
                ekb1.setFtbl(ftbl);
            }
            if (ToolUtil.isNotEmpty(ftjes)) {
                ekb1.setFtje(ftjes);
            }
            ekb1.setFtbz(0);
            ekb1.setSumAmount(BigDecimal.ZERO);
            ekbService.updateById(ekb1);
        }
    }

    @Test
    public void ekbHd() {
        try {
            logger.info("===定时更新易快报支付状态开始===");
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            JSONObject json = new JSONObject();
            json.put("appKey", "32de31e8-9a31-4cf9-a69b-74ddee365cf2");
            json.put("appSecurity", "149b3780-99bf-4431-976e-27d80896452f");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            String url = "https://dd2.ekuaibao.com/api/openapi/v1/auth/getAccessToken";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取accessToken
            String accessToken = jo.get("value").getAsJsonObject().get("accessToken").getAsString();
            String url1 = "https://dd2.ekuaibao.com/api/outbound/v1/approval?accessToken=" + accessToken;
            //获取已付款的易快报报销单
            //List<BtyEkb> list = ekbService.list(new QueryWrapper<BtyEkb>().eq("flag", 1).eq("state", 0).isNotNull("ekb_id").ge("cjsj", "2021-10-01"));
            List<BtyEkb> list = ekbService.list(new QueryWrapper<BtyEkb>().eq("flag", 1).eq("state", 0).isNotNull("ekb_id").ge("cjsj", "2021-10-01"));
            if (list.size() > 0) {
                for (BtyEkb ekb : list) {
                    JSONObject jsons = new JSONObject();
                    jsons.put("signKey", "u5UjcqCJCX0g");
                    jsons.put("flowId", ekb.getEkbId());
                    jsons.put("nodeId", ekb.getNodeId());
                    jsons.put("action", "accept");
                    jsons.put("comment", "同意");

                    HttpEntity<String> formEntity1 = new HttpEntity<String>(jsons.toString(), headers);
                    String result1 = restTemplate.postForEntity(url1, formEntity1, String.class).getBody();
                    System.out.println("result1:" + result1);
                    //将json字符串转化成json对象
                    JsonObject jo1 = jp.parse(result1).getAsJsonObject();
                    //获取返回的状态码code
                    String code = jo1.get("value").getAsJsonObject().get("code").getAsString();
                    String date = DateUtil.getNowDate();
                    if (code.equals("204")) {
                        BtyEkbParam param = new BtyEkbParam();
                        param.setCode(ekb.getCode());
                        param.setState(1);
                        param.setZfrq(date);
                        ekbService.updateByCode(param);
                    }
                }
            }
            logger.info("===定时更新易快报支付状态完成:{}条数据===" + list.size());
        } catch (Exception e) {
            logger.info("===定时更新易快报支付状态出现异常===" + e);
            e.printStackTrace();
        }
    }

    @Test
    public void ekbSqd() {
        try {
            logger.info("===定时更新易快报支付状态开始===");
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            JSONObject json = new JSONObject();
            json.put("appKey", "32de31e8-9a31-4cf9-a69b-74ddee365cf2");
            json.put("appSecurity", "149b3780-99bf-4431-976e-27d80896452f");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            String url = "https://dd2.ekuaibao.com/api/openapi/v1/auth/getAccessToken";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取accessToken
            String accessToken = jo.get("value").getAsJsonObject().get("accessToken").getAsString();
            String url1 = "https://dd2.ekuaibao.com/api/outbound/v1/approval?accessToken=" + accessToken;
            //获取已付款的易快报报销单
            List<BtyEkb> list = ekbService.list(new QueryWrapper<BtyEkb>().eq("flag", 1).eq("state", 0).isNotNull("ekb_id").ge("cjsj", "2021-10-01"));
            if (list.size() > 0) {
                for (BtyEkb ekb : list) {
                    JSONObject jsons = new JSONObject();
                    jsons.put("signKey", "ZrpkLjI2IHuz");
                    jsons.put("flowId", ekb.getEkbId());
                    jsons.put("nodeId", ekb.getNodeId());
                    jsons.put("action", "accept");
                    jsons.put("comment", "同意");

                    HttpEntity<String> formEntity1 = new HttpEntity<String>(jsons.toString(), headers);
                    String result1 = restTemplate.postForEntity(url1, formEntity1, String.class).getBody();
                    System.out.println("result1:" + result1);
                    logger.info("result1:" + result1);
                    //将json字符串转化成json对象
                    JsonObject jo1 = jp.parse(result1).getAsJsonObject();
                    //获取返回的状态码code
                    String code = jo1.get("value").getAsJsonObject().get("code").getAsString();
                    String date = DateUtil.getNowDate();
                    if (code.equals("204")) {
//                        ekb.setState(1);
//                        ekb.setZfrq(date);
//                        ekbService.updateById(ekb);
                        BtyEkbParam param = new BtyEkbParam();
                        param.setCode(ekb.getCode());
                        param.setState(1);
                        param.setZfrq(date);
                        ekbService.updateByCode(param);
                    }
                }
            }
            logger.info("===定时更新易快报申请单支付状态完成:{}条数据===" + list.size());
        } catch (Exception e) {
            logger.info("===定时更新易快报支付状态出现异常===" + e);
            e.printStackTrace();
        }
    }

    @Test
    public void yyTest() {

        BigDecimal zfbsxf = BigDecimal.ZERO;
        BigDecimal wxsxf = BigDecimal.ZERO;
        BigDecimal mdsxf = BigDecimal.ZERO;
        BigDecimal mtsxf = BigDecimal.ZERO;
        YybbParam yybbParam = new YybbParam();
        YybbResult yybb = yybbMapper.getSxfByDm(yybbParam);
        //获取单店的支付宝手续费，微信手续费，买单手续费，美团手续费
        if (ToolUtil.isNotEmpty(yybb)) {
            zfbsxf = yybb.getZfbsxf();
            wxsxf = yybb.getWxsxf();
            mdsxf = yybb.getMdsxf();
            mtsxf = yybb.getMtsxf();
        }
        List<YybbResult> list = yybbMapper.bankListByDm(yybbParam);
        //美团团购
        BigDecimal mttg = BigDecimal.ZERO;
        //美团买单
        BigDecimal mtmd = BigDecimal.ZERO;
        //微信
        BigDecimal wx = BigDecimal.ZERO;
        //会员卡
        BigDecimal hyk = BigDecimal.ZERO;
        //现金
        BigDecimal xj = BigDecimal.ZERO;
        //支付宝
        BigDecimal zfb = BigDecimal.ZERO;
        //美团外卖
        BigDecimal mtwm = BigDecimal.ZERO;
        String yaoma = "";
        String yhk = "";
        for (YybbResult yybbResult : list) {
            String zy = yybbResult.getZy() == null ? "" : yybbResult.getZy();
            if (zy.contains("美团团购")) {
                mttg = mttg.add(yybbResult.getSr());
            } else if (zy.contains("美团买单")) {
                mtmd = mtmd.add(yybbResult.getSr());
            } else if (zy.contains("微信分")) {
                wx = wx.add(yybbResult.getSr());
            } else if (zy.contains("会员分")) {
                hyk = hyk.add(yybbResult.getSr());
            } else if (zy.contains("xj")) {
                xj = xj.add(yybbResult.getSr());
            } else if (zy.contains("宝宝分")) {
                zfb = zfb.add(yybbResult.getSr());
            } else if (zy.contains("美团外卖")) {
                mtwm = mtwm.add(yybbResult.getSr());
            }
        }

        int mttgFlag = mttg.compareTo(BigDecimal.ZERO);
        int mtmdFlag = mtmd.compareTo(BigDecimal.ZERO);
        int wxFlag = wx.compareTo(BigDecimal.ZERO);
        int hykFlag = hyk.compareTo(BigDecimal.ZERO);
        int xjFlag = xj.compareTo(BigDecimal.ZERO);
        int zfbFlag = zfb.compareTo(BigDecimal.ZERO);
        int mtwmFlag = mtwm.compareTo(BigDecimal.ZERO);
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
        headers.add("system", "001"); // 系统编码
        headers.add("usercode", "15253172037"); // 用户
        headers.add("password", "514576f58a89767b46c1b44767a08f77");
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        BigDecimal mtDf = mtsxf.add(mttg);
        BigDecimal mdDf = mdsxf.add(mtmd);
        BigDecimal wxDf = wxsxf.add(wx);
        BigDecimal zfbDf = zfbsxf.add(zfb);
        StringBuilder sb = new StringBuilder();
        sb.append("{\n" +
                "    \"voucher\":[\n" +
                "        {\n" +
                "            \"details\":[");
        //美团团购金额大于0的话，生成美团团购的凭证
        if (mttgFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + mtsxf + ",\n" +
                    "                    \"explanation\":\"美团服务费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660120\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + mttg + ",\n" +
                    "                    \"explanation\":\"收美团\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0031\"\n" + //美团团购编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + mtDf + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收美团\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112205\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        //美团买单金额大于0的话，生成美团买单的凭证
        if (mtmdFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + mdsxf + ",\n" +
                    "                    \"explanation\":\"买单手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660301\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + mtmd + ",\n" +
                    "                    \"explanation\":\"收买单\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0015\"\n" + //点评买单编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + mdDf + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收买单\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112208\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        if (wxFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + wxsxf + ",\n" +
                    "                    \"explanation\":\"微信手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660301\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + wx + ",\n" +
                    "                    \"explanation\":\"收微信\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0172\"\n" + //微信收款编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + wxDf + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收微信\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112206\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        if (hykFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + hyk + ",\n" +
                    "                    \"explanation\":\"收会员卡\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0022\"\n" + //会员卡储值编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + hyk + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收会员卡\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112210\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        if (xjFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + xj + ",\n" +
                    "                    \"explanation\":\"收现金\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0038\"\n" + //人民币编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + xj + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收现金\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112203\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        if (zfbFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        }\n" +
                    "                    ],\n" +

                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + zfbsxf + ",\n" +
                    "                    \"explanation\":\"支付宝手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660301\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + zfb + ",\n" +
                    "                    \"explanation\":\"收支付宝\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0189\"\n" + //支付宝收款编号
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":" + zfbDf + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收支付宝\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112207\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
        }
        if (mtwmFlag == 1) {
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":" + yhk + "\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    //借方科目
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":" + mtwm + ",\n" +
                    "                    \"explanation\":\"收美团外卖\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    //贷方辅助核算
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0035\"\n" + //美团外卖编号
                    "                        }\n" +
                    "                    ],\n" +
                    //贷方科目
                    "                    \"creditamount\":" + mtwm + ",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"收美团外卖\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112211\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                }\n");
        }
        sb.append("            ],\n" +
                "            \"pk_corp\":\"303\",\n" +
                "            \"pk_glorgbook\":\"303-bty01\",\n" +
                "            \"pk_prepared\":\"15253172037\",\n" +
                "            \"pk_vouchertype\":\"记账\"\n" +
                "        }\n" +
                "    ]\n" +
                "}");

        String json = "{\n" +
                "    \"voucher\":[\n" +
                "        {\n" +
                "            \"details\":[\n" +
                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + mtsxf + ",\n" +
                "                    \"explanation\":\"美团服务费\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"660120\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + mttg + ",\n" +
                "                    \"explanation\":\"收美团\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0031\"\n" + //美团团购编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + mtDf + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收美团\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112205\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +

                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + mdsxf + ",\n" +
                "                    \"explanation\":\"买单手续费\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"660301\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + mtmd + ",\n" +
                "                    \"explanation\":\"收买单\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0015\"\n" + //点评买单编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + mdDf + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收买单\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112208\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +
                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + wxsxf + ",\n" +
                "                    \"explanation\":\"微信手续费\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"660301\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + wx + ",\n" +
                "                    \"explanation\":\"收微信\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0172\"\n" + //微信收款编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + wxDf + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收微信\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112206\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +

                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + hyk + ",\n" +
                "                    \"explanation\":\"收会员卡\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0022\"\n" + //会员卡储值编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + hyk + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收会员卡\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112210\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +

                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + xj + ",\n" +
                "                    \"explanation\":\"收现金\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0038\"\n" + //人民币编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + xj + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收现金\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112203\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +

                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        }\n" +
                "                    ],\n" +

                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + zfbsxf + ",\n" +
                "                    \"explanation\":\"支付宝手续费\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"660301\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + zfb + ",\n" +
                "                    \"explanation\":\"收支付宝\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0189\"\n" + //支付宝收款编号
                "                        }\n" +
                "                    ],\n" +
                "                    \"creditamount\":" + zfbDf + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收支付宝\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112207\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                },\n" +
                //借方辅助核算
                "                {\n" +
                "                    \"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"96\",\n" +
                "                            \"checkvaluecode\":" + yhk + "\n" +
                "                        }\n" +
                "                    ],\n" +
                //借方科目
                "                    \"creditamount\":\"\",\n" +
                "                    \"debitamount\":" + mtwm + ",\n" +
                "                    \"explanation\":\"收美团外卖\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"100202\",\n" +
                "                    \"pk_currtype\":\"CNY\"\n" +
                "                }," +
                "{\n" +
                //贷方辅助核算
                "\t\t\t\t\"ass\":[\n" +
                "                        {\n" +
                "                            \"checktypecode\":\"2\",\n" +
                "                            \"checkvaluecode\":'" + yaoma + "'\n" +
                "                        },\n" +
                "\t\t\t\t\t\t{\n" +
                "                            \"checktypecode\":\"7\",\n" +
                "                            \"checkvaluecode\":\"0035\"\n" + //美团外卖编号
                "                        }\n" +
                "                    ],\n" +
                //贷方科目
                "                    \"creditamount\":" + mtwm + ",\n" +
                "                    \"creditquantity\":\"\",\n" +
                "                    \"debitamount\":\"\",\n" +
                "                    \"debitquantity\":\"\",\n" +
                "                    \"detailindex\":\"\",\n" +
                "                    \"excrate1\":\"\",\n" +
                "                    \"explanation\":\"收美团外卖\",\n" +
                "                    \"localcreditamount\":\"\",\n" +
                "                    \"localdebitamount\":\"\",\n" +
                "                    \"pk_accsubj\":\"112211\",\n" +
                "                    \"pk_currtype\":\"CNY\",\n" +
                "                    \"price\":\"\"\n" +
                "                }\n" +

                "            ],\n" +
                "            \"pk_corp\":\"303\",\n" +
                "            \"pk_glorgbook\":\"303-bty01\",\n" +
                "            \"pk_prepared\":\"15253172037\",\n" +
                "            \"pk_vouchertype\":\"记账\"\n" +
                "        }\n" +
                "    ]\n" +
                "}";
        HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
        String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();

        System.out.println("result:" + result);

    }
    @Test
    public  void pzTest(){
        String month1= DateUtil.getLastMonthDayStr();
        String month=DateUtil.getLastDayByMonth(month1);
        List<BtyElmsxfResult>list=elmsxfMapper.dmListByMdId();
        for (BtyElmsxfResult elmResult : list) {
            BigDecimal tbje=elmResult.getTbje();
            String bh=elmResult.getBh();
            String yaoma=elmResult.getYaoma();
            String mdid=elmResult.getMdid();
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
            headers.add("system", "001"); // 系统编码
            headers.add("usercode", "15253172037"); // 用户
            headers.add("password", "514576f58a89767b46c1b44767a08f77");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());

            StringBuilder sb=new StringBuilder();
            sb.append("{\n" +
                    "    \"voucher\":[\n" +
                    "        {\n" +
                    "            \"details\":[");

            //饿了么手续费凭证
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":\""+tbje+"\",\n" +
                    "                    \"explanation\":\"饿了么手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660301\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0019\"\n" +//饿了么外卖辅助核算编码
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\""+tbje+"\",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"饿了么手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112212\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
            sb.append("            ],\n" +
                    "            \"pk_corp\":"+bh+",\n" +
                    "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                    "            \"pk_prepared\":\"15253172037\",\n" +
                    "            \"pk_vouchertype\":\"记账\",\n" +
                    "            \"prepareddate\":\"2021-10-15\"\n" +
                    "        }\n" +
                    "    ]\n" +
                    "}");
           // System.out.println("sb:"+sb.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
            String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:"+result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String status = jo.get("status").getAsString();

            if(status.equals("falied")){
                String errormsg = jo.get("errormsg").getAsString();
                BtyElmsxf sxf=elmsxfMapper.selectOne(new QueryWrapper<BtyElmsxf>().eq("mdid",mdid));
                if(ToolUtil.isNotEmpty(sxf)){
                    sxf.setErrormsg(errormsg);
                    elmsxfMapper.updateById(sxf);
                }
                System.out.println("errormsg:"+errormsg);
                //return  ResponseData.error(501,errormsg);
            }else{
                BtyElmsxf sxf=elmsxfMapper.selectOne(new QueryWrapper<BtyElmsxf>().eq("mdid",mdid));
                if(ToolUtil.isNotEmpty(sxf)){
                    sxf.setFlag(1);
                    elmsxfMapper.updateById(sxf);
                }
                System.out.println("凭证导入成功！");
                //return ResponseData.success();
            }
        }
    }

    @Test
    public void salesDataWcc() {
        try {
            logger.info("===更新南翔五彩城数据开始...");
            String today = DateUtil.getToday4Oclock();
            String nextday = DateUtil.getNextDay4Oclock();
            Timestamp todayTime = Timestamp.valueOf(today);
            Timestamp nextdayTime = Timestamp.valueOf(nextday);
            //获取南翔五彩城销售额
            //String money = bizService.lastMoneyByShopCode("831", todayTime, nextdayTime);
            String money="";
            if (ToolUtil.isEmpty(money)) {
                money = "0";
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            String now = sdf.format(new Date());
            String nowDate = DateUtil.getStampNow();
            logger.info("南翔五彩城销售额：" + money);
            String str[] = {};
            Map map = new HashMap();
            map.put("cardBank", "");
            map.put("cardNumber", "");
            map.put("discountAmt", 0);
            map.put("payAmt", money);
            map.put("paymentMethod", "CH");
            map.put("time", nowDate);
            map.put("value", money);
            List<Map<String, Object>> payList = new ArrayList<>();
            payList.add(map);

            RestTemplate restTemplate = new RestTemplate();
            JSONObject dataJson = new JSONObject();
            //收银员编号
            dataJson.put("cashierId", "0302a101b5l207n0401");
            //店铺验证密钥
            dataJson.put("checkCode", "88888888");
            //备注
            dataJson.put("comments", "comments");
            dataJson.put("itemList", str);
            //商场编号
            dataJson.put("mall", "0302A101");
            dataJson.put("mobile", "");
            //订单号
            dataJson.put("orderId", nowDate);
            dataJson.put("payList", payList);
            dataJson.put("refOrderId", "refOrderId");
            //店铺编号
            dataJson.put("store", "B5L207N04");
            //收银机编号
            dataJson.put("tillId", "01");
            dataJson.put("time", nowDate);
            //订单总金额
            dataJson.put("totalAmt", money);
            dataJson.put("type", "SALE");
            //dataJson.put("type", "ONLINEREFUND");
            //来源 01 店铺 02数据采集盒子
            dataJson.put("source", "01");
            //合作伙伴身份标识
            String Partner_ID = "70000006";
            //调用的API版本号
             String Api_Version = "1.0.0";
            //String Api_Version = "1.0.1";
            //被调用API的应用编码
            String App_Sub_ID = "10000133334KE";
            //API调用的API编码
            String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
            //API调用方授权令牌
            String App_Token = "b6c5606845244fc38a6453e33680cbba";
            //被调用API的应用编码
            String App_Pub_ID = "10000133301US";
            //合作伙伴系统编码
            String Sys_ID = "100001333";

            //拼接待签名字符串
            String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                    dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
            //生成签名获取sign的值
            String sign = Md5Util.md5(strs);
            System.out.println("strs:" + strs);
            System.out.println("sign:" + sign);

            JSONObject contentJson = new JSONObject();
            contentJson.put("Partner_ID", Partner_ID);
            contentJson.put("Api_Version", Api_Version);
            contentJson.put("App_Sub_ID", App_Sub_ID);
            //响应格式,默认为json格式，可选值：xml或json
            contentJson.put("Format", "json");
            //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
            contentJson.put("Time_Stamp", now);
            contentJson.put("Api_ID", Api_ID);
            contentJson.put("App_Token", App_Token);
            contentJson.put("App_Pub_ID", App_Pub_ID);
            //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
            contentJson.put("Sign_Method", "md5");
            //服务请求的签名字符串
            contentJson.put("Sign", sign);
            contentJson.put("Sys_ID", Sys_ID);
            JSONObject jsons = new JSONObject();
            jsons.put("REQUEST_DATA", dataJson);
            jsons.put("HRT_ATTRS", contentJson);

            JSONObject json = new JSONObject();
            json.put("REQUEST", jsons);
            System.out.println("REQUEST_DATA:" + dataJson);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            //正式环境
            //String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
            //测试环境
            String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
            String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
            if (errcode.equals("0000")) {
                System.out.println("南翔五彩城销售数据更新成功！");
                logger.info("===南翔五彩城销售数据更新成功！");
            } else {
                System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
                logger.info("错误码：" + errcode + "错误信息:" + errmsg);
            }
        } catch (Exception e) {
            logger.error("更新南翔五彩城销售数据 出现异常", e);
            e.printStackTrace();
        }
    }

    @Test
    public void salesDataWccProd() {
        try {
            logger.info("===更新南翔五彩城数据开始...");
            String today = DateUtil.getToday4Oclock();
            String nextday = DateUtil.getNextDay4Oclock();
            Timestamp todayTime = Timestamp.valueOf(today);
            Timestamp nextdayTime = Timestamp.valueOf(nextday);
            //获取南翔五彩城销售额
            String money = bizService.lastMoneyByShopCode("983", todayTime, nextdayTime);
            if (ToolUtil.isEmpty(money)) {
                money = "0";
            }
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
            String now = sdf.format(new Date());
            String nowDate = DateUtil.getStampNow();
            logger.info("南翔五彩城销售额：" + money);
            String str[] = {};
            Map map = new HashMap();
            map.put("cardBank", "");
            map.put("cardNumber", "");
            map.put("discountAmt", 0);
            map.put("payAmt", money);
            map.put("paymentMethod", "CH");
            map.put("time", nowDate);
            map.put("value", money);
            List<Map<String, Object>> payList = new ArrayList<>();
            payList.add(map);

            RestTemplate restTemplate = new RestTemplate();
            JSONObject dataJson = new JSONObject();
            //收银员编号
            dataJson.put("cashierId", "0302a101gl318n0101");
            //店铺验证密钥
            dataJson.put("checkCode", "p88888888");
            //备注
            dataJson.put("comments", "comments");
            dataJson.put("itemList", str);
            //商场编号
            dataJson.put("mall", "0302A101");
            dataJson.put("mobile", "");
            //订单号
            dataJson.put("orderId", nowDate);
            dataJson.put("payList", payList);
            dataJson.put("refOrderId", "refOrderId");
            //店铺编号
            dataJson.put("store", "GL318N01");
            //收银机编号
            dataJson.put("tillId", "01");
            dataJson.put("time", nowDate);
            //订单总金额
            dataJson.put("totalAmt", money);
            dataJson.put("type", "SALE");
            //dataJson.put("type", "ONLINEREFUND");
            //来源 01 店铺 02数据采集盒子
            dataJson.put("source", "01");
            //合作伙伴身份标识
            String Partner_ID = "70000029";
            //调用的API版本号
            String Api_Version = "1.0.1";
            //String Api_Version = "1.0.1";
            //被调用API的应用编码
            String App_Sub_ID = "10000187223YB";
            //API调用的API编码
            String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
            //API调用方授权令牌
            String App_Token = "7749e69c033845f587c08991416eba59";
            //被调用API的应用编码
            String App_Pub_ID = "10000187223RL";
            //合作伙伴系统编码
            String Sys_ID = "100001872";

            //拼接待签名字符串
            String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                    dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
            //生成签名获取sign的值
            String sign = Md5Util.md5(strs);
            System.out.println("strs:" + strs);
            System.out.println("sign:" + sign);

            JSONObject contentJson = new JSONObject();
            contentJson.put("Partner_ID", Partner_ID);
            contentJson.put("Api_Version", Api_Version);
            contentJson.put("App_Sub_ID", App_Sub_ID);
            //响应格式,默认为json格式，可选值：xml或json
            contentJson.put("Format", "json");
            //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
            contentJson.put("Time_Stamp", now);
            contentJson.put("Api_ID", Api_ID);
            contentJson.put("App_Token", App_Token);
            contentJson.put("App_Pub_ID", App_Pub_ID);
            //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
            contentJson.put("Sign_Method", "md5");
            //服务请求的签名字符串
            contentJson.put("Sign", sign);
            contentJson.put("Sys_ID", Sys_ID);
            JSONObject jsons = new JSONObject();
            jsons.put("REQUEST_DATA", dataJson);
            jsons.put("HRT_ATTRS", contentJson);

            JSONObject json = new JSONObject();
            json.put("REQUEST", jsons);
            System.out.println("REQUEST_DATA:" + dataJson);
            System.out.println("json:" + json);
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
            //正式环境
            String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
            //测试环境
            //String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:" + result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
            String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
            if (errcode.equals("0000")) {
                System.out.println("南翔五彩城销售数据更新成功！");
                logger.info("===南翔五彩城销售数据更新成功！");
            } else {
                System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
                logger.info("错误码：" + errcode + "错误信息:" + errmsg);
            }
        } catch (Exception e) {
            logger.error("更新南翔五彩城销售数据 出现异常", e);
            e.printStackTrace();
        }
    }

    /**
     * 其它入库单 494 实际138
     */
    @Test
   public  void psd(){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
        headers.add("system", "001"); // 系统编码
        headers.add("usercode", "15253172037"); // 用户
        headers.add("password", "514576f58a89767b46c1b44767a08f77");
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        //库存其他入库单查询
        //fbillflag(单据状态):1（删除）2（自由）3（签字）4（存货系统审核） ,"fbillflag":"4" ,"page_now":"1","page_size":"9999"
        String json = "{\"corp\":\"201\",\"date_begin\":\"2021-10-01\",\"date_end\":\"2021-10-31\"}";
        HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
        String url = "http://124.70.28.147:8088/u8cloud/api/ic/otherin/query";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();

        logger.info("其它入库单:"+result);
//        System.out.println("result:"+result);

        Yfd yfd = restTemplate.postForEntity(url, formEntity, Yfd.class).getBody();
        JSONObject resultObject = JSON.parseObject(yfd.getData());
        JSONArray jsonArray = resultObject.getJSONArray("datas");
        JSONObject jsonObject;
        int size=0;
        if (jsonArray != null) {
            for (int i = 0; i < jsonArray.size(); i++) {
                jsonObject = jsonArray.getJSONObject(i);
                RkdData.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", RkdData.DatasBean.ParentvoBean.class);
                List<RkdData.DatasBean.ChildrenvoBean> childrenvo = JSON.parseArray(jsonObject.get("childrenvo").toString(), RkdData.DatasBean.ChildrenvoBean.class);
                size=size+childrenvo.size();
                for (RkdData.DatasBean.ChildrenvoBean childrenvoBean : childrenvo) {
                BtyPsd psd=new BtyPsd();
                psd.setCdispatcherid(parentvo.getCdispatcherid());
                psd.setDispatcherCode(parentvo.getDispatcher_code());
                psd.setDispatcherName(parentvo.getDispatcher_name());
                psd.setCdptid(parentvo.getCdptid());
                psd.setDeptCode(parentvo.getDept_code());
                psd.setDeptName(parentvo.getDept_name());
                psd.setCoperatorid(parentvo.getCoperatorid());
                psd.setOperatorCode(parentvo.getOperator_code());
                psd.setOperatorName(parentvo.getOperator_name());
                psd.setCwarehouseid(parentvo.getCwarehouseid());
                psd.setWarehouseidCode(parentvo.getWarehouseid_code());
                psd.setWarehouseidName(parentvo.getWarehouseid_name());
                psd.setPkCalbody(parentvo.getPk_calbody());
                psd.setCalbodyCode(parentvo.getCalbody_code());
                psd.setCalbodyName(parentvo.getCalbody_name());
                psd.setPkCorp(parentvo.getPk_corp());
                psd.setCorpCode(parentvo.getCorp_code());
                psd.setCorpName(parentvo.getCorp_name());
                psd.setDaccountdate(parentvo.getDaccountdate());
                psd.setTaccounttime(parentvo.getTaccounttime());
                psd.setTmaketime(parentvo.getTmaketime());
                psd.setCbilltypecode(parentvo.getCbilltypecode());
                psd.setVnote(parentvo.getVnote());
                psd.setVbillcode(parentvo.getVbillcode());
                psd.setDbilldate(parentvo.getDbilldate());
                psd.setCcustomerid(parentvo.getCcustomerid());
                psd.setCustomerCode(parentvo.getCustomer_code());
                psd.setCustomerName(parentvo.getCustomer_name());

                //childrenvo
                psd.setCinventoryid(childrenvoBean.getCinventoryid());
                psd.setNinnum(childrenvoBean.getNinnum());
                psd.setNprice(childrenvoBean.getNprice());
                psd.setNmny(childrenvoBean.getNmny());
                psd.setDbizdate(childrenvoBean.getDbizdate());
                psd.setCbodywarehouseid(childrenvoBean.getCbodywarehouseid());
                psd.setBodywarehouseCode(childrenvoBean.getBodywarehouse_code());
                psd.setBodywarehouseName(childrenvoBean.getBodywarehouse_name());
                psd.setVuserdef4(childrenvoBean.getVuserdef4());
                psd.setVuserdef5(childrenvoBean.getVuserdef5());
                psdService.save(psd);
                }
            }
            System.out.println("size:"+size);
        }
   }

    /**
     * 其它出库单11340
     */
    @Test
    public  void psckd(){
        int num=1;
        int shang;
        String hid ="";
        String bid="";
        do{
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
        headers.add("system", "001"); // 系统编码
        headers.add("usercode", "15253172037"); // 用户
        headers.add("password", "514576f58a89767b46c1b44767a08f77");
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        //库存其他出库单查询
        //fbillflag(单据状态):1（删除）2（自由）3（签字）4（存货系统审核）,"fbillflag":"4"  page_now
        String json = "{\"corp\":\"201\",\"date_begin\":\"2021-12-01\",\"date_end\":\"2021-12-31\",\"page_now\":\""+num+"\"}";
        logger.info("num:"+num);
        HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
        String url = "http://124.70.28.147:8088/u8cloud/api/ic/otherout/query";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();

        //logger.info("result:"+result);
       // System.out.println("result:"+result);

            com.alibaba.fastjson.JSONObject jsonObj = JSON.parseObject(result);
            com.alibaba.fastjson.JSONObject jsonObj1 = JSON.parseObject(jsonObj.get("data").toString());
            com.alibaba.fastjson.JSONArray jsonArray = jsonObj1.getJSONArray("datas");

        //Yfd yfd = restTemplate.postForEntity(url, formEntity, Yfd.class).getBody();
        //JSONObject resultObject = JSON.parseObject(yfd.getData());
       // JSONArray jsonArray = resultObject.getJSONArray("datas");
            //int allcount=resultObject.getInteger("allcount");
            int allcount=11340;
            shang=allcount/1000;
            int yushu=allcount%1000;
            if(shang>0&&yushu>0){
                shang+=1;
            }
        System.out.println("allcount:"+allcount);

        JSONObject jsonObject;
        int size=0;

            for (int i = 0; i < jsonArray.size(); i++) {
                com.alibaba.fastjson.JSONObject resultsku = jsonArray.getJSONObject(i);
                com.alibaba.fastjson.JSONObject head = resultsku.getJSONObject("parentvo");
                //CkdData.DatasBean.ParentvoBean parentvo = resultsku.getObject("parentvo", CkdData.DatasBean.ParentvoBean.class);
                com.alibaba.fastjson.JSONArray body = resultsku.getJSONArray("childrenvo");
                String hidd = head.getString("cgeneralhid");
                if(!hid.contains(hidd)){
                    hid += hidd+",";
                }
                for(int x = 0;x<body.size();x++){
                    com.alibaba.fastjson.JSONObject resultsbo = body.getJSONObject(x);
                    String bhid = resultsbo.getString("cgeneralhid");
                    String bbid = resultsbo.getString("cgeneralbid");
                    if(!hid.contains(bhid+","+bbid)){
                        bid += bhid+","+bbid+";";

                    BtyPsd psd=new BtyPsd();
                    psd.setCdispatcherid(head.getString("cdispatcherid"));
                    psd.setDispatcherCode(head.getString("dispatcher_code"));
                    psd.setDispatcherName(head.getString("dispatcher_name"));
                    psd.setCdptid(head.getString("cdptid"));
                    psd.setDeptCode(head.getString("dept_code"));
                    psd.setDeptName(head.getString("dept_name"));
                    psd.setCoperatorid(head.getString("coperatorid"));
                    psd.setOperatorCode(head.getString("operator_code"));
                    psd.setOperatorName(head.getString("operator_name"));
                    psd.setCwarehouseid(head.getString("cwarehouseid"));
                    psd.setWarehouseidCode(head.getString("warehouseid_code"));
                    psd.setWarehouseidName(head.getString("warehouseid_name"));
                    psd.setPkCalbody(head.getString("pk_calbody"));
                    psd.setCalbodyCode(head.getString("calbody_code"));
                    psd.setCalbodyName(head.getString("calbody_name"));
                    psd.setPkCorp(head.getString("pk_corp"));
                    psd.setCorpCode(head.getString("corp_code"));
                    psd.setCorpName(head.getString("corp_name"));
                    psd.setDaccountdate(head.getString("daccountdate"));
                    psd.setTaccounttime(head.getString("taccounttime"));
                    psd.setTmaketime(head.getString("tmaketime"));
                    psd.setCbilltypecode(head.getString("cbilltypecode"));
                    psd.setVnote(head.getString("vnote"));
                    psd.setVbillcode(head.getString("vbillcode"));
                    psd.setDbilldate(head.getString("dbilldate"));
                    psd.setCcustomerid(head.getString("ccustomerid"));
                    psd.setCustomerCode(head.getString("customer_code"));
                    psd.setCustomerName(head.getString("customer_name"));
                    //psd.setCgeneralhid(head.getString("cgeneralhid"));
                    //childrenvo
                    psd.setCrowno(resultsbo.getString("crowno"));
                    psd.setCinventoryid(resultsbo.getString("cinventoryid"));
                    psd.setNoutnum(resultsbo.getInteger("noutnum"));
                    psd.setNprice(resultsbo.getBigDecimal("nprice"));
                    psd.setNmny(resultsbo.getBigDecimal("nmny"));
                    psd.setDbizdate(resultsbo.getString("dbizdate"));
                    psd.setCbodywarehouseid(resultsbo.getString("cbodywarehouseid"));
                    psd.setBodywarehouseCode(resultsbo.getString("bodywarehouse_code"));
                    psd.setBodywarehouseName(resultsbo.getString("bodywarehouse_name"));
                    psd.setNbarcodenum(resultsbo.getInteger("nbarcodenum"));
                    psd.setVuserdef4(resultsbo.getString("vuserdef4"));
                    psd.setVuserdef5(resultsbo.getString("vuserdef5"));
                    psd.setInventoryCode(resultsbo.getString("inventory_code"));
                    psd.setInventoryName(resultsbo.getString("inventory_name"));
                    psd.setInvspec(resultsbo.getString("invspec"));
                    psd.setCvendorid(resultsbo.getString("cvendorid"));
                    psd.setVendorCode(resultsbo.getString("vendor_code"));
                    psd.setVendorName(resultsbo.getString("vendor_name"));
                    psd.setCgeneralbid(resultsbo.getString("cgeneralbid"));
                    psd.setCgeneralhid(resultsbo.getString("cgeneralhid"));
                    psdService.save(psd);
                    }
                }

//                jsonObject = jsonArray.getJSONObject(i);
//                CkdData.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", CkdData.DatasBean.ParentvoBean.class);
//               List<CkdData.DatasBean.ChildrenvoBean> childrenvo = JSON.parseArray(jsonObject.get("childrenvo").toString(), CkdData.DatasBean.ChildrenvoBean.class);
//                size=size+childrenvo.size();
//                for (CkdData.DatasBean.ChildrenvoBean childrenvoBean : childrenvo) {
//
//                 BtyPsd psd=new BtyPsd();
//
//                psd.setCdispatcherid(parentvo.getCdispatcherid());
//                psd.setDispatcherCode(parentvo.getDispatcher_code());
//                psd.setDispatcherName(parentvo.getDispatcher_name());
//                psd.setCdptid(parentvo.getCdptid());
//                psd.setDeptCode(parentvo.getDept_code());
//                psd.setDeptName(parentvo.getDept_name());
//                psd.setCoperatorid(parentvo.getCoperatorid());
//                psd.setOperatorCode(parentvo.getOperator_code());
//                psd.setOperatorName(parentvo.getOperator_name());
//                psd.setCwarehouseid(parentvo.getCwarehouseid());
//                psd.setWarehouseidCode(parentvo.getWarehouseid_code());
//                psd.setWarehouseidName(parentvo.getWarehouseid_name());
//                psd.setPkCalbody(parentvo.getPk_calbody());
//                psd.setCalbodyCode(parentvo.getCalbody_code());
//                psd.setCalbodyName(parentvo.getCalbody_name());
//                psd.setPkCorp(parentvo.getPk_corp());
//                psd.setCorpCode(parentvo.getCorp_code());
//                psd.setCorpName(parentvo.getCorp_name());
//                psd.setDaccountdate(parentvo.getDaccountdate());
//                psd.setTaccounttime(parentvo.getTaccounttime());
//                psd.setTmaketime(parentvo.getTmaketime());
//                psd.setCbilltypecode(parentvo.getCbilltypecode());
//                psd.setVnote(parentvo.getVnote());
//                psd.setVbillcode(parentvo.getVbillcode());
//                psd.setDbilldate(parentvo.getDbilldate());
//                psd.setCcustomerid(parentvo.getCcustomerid());
//                psd.setCustomerCode(parentvo.getCustomer_code());
//                psd.setCustomerName(parentvo.getCustomer_name());
//                psd.setCgeneralhid(parentvo.getCgeneralhid());
//                //childrenvo
//                psd.setCrowno(childrenvoBean.getCrowno());
//                psd.setCinventoryid(childrenvoBean.getCinventoryid());
//                psd.setNoutnum(childrenvoBean.getNoutnum());
//                psd.setNprice(childrenvoBean.getNprice());
//                psd.setNmny(childrenvoBean.getNmny());
//                psd.setDbizdate(childrenvoBean.getDbizdate());
//                psd.setCbodywarehouseid(childrenvoBean.getCbodywarehouseid());
//                psd.setBodywarehouseCode(childrenvoBean.getBodywarehouse_code());
//                psd.setBodywarehouseName(childrenvoBean.getBodywarehouse_name());
//                psd.setNbarcodenum(childrenvoBean.getNbarcodenum());
//                psd.setVuserdef4(childrenvoBean.getVuserdef4());
//                psd.setVuserdef5(childrenvoBean.getVuserdef5());
//                psd.setInventoryCode(childrenvoBean.getInventory_code());
//                psd.setInventoryName(childrenvoBean.getInventory_name());
//                psd.setInvspec(childrenvoBean.getInvspec());
//                psd.setCvendorid(childrenvoBean.getCvendorid());
//                psd.setVendorCode(childrenvoBean.getVendor_code());
//                psd.setVendorName(childrenvoBean.getVendor_name());
//                psd.setCgeneralbid(childrenvoBean.getCgeneralbid());
//
//                psdService.save(psd);
//
              //  }

            }

            System.out.println("size:"+size);
        num++;
        }while ((num-1)!=shang);

        System.out.println(hid.split(",").length);
        System.out.println(bid.split(";").length);

    }
    /**
     * 销售出库单  174  实际166
     */
    @Test
    public  void xsckd(){
        RestTemplate restTemplate = new RestTemplate();
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
        headers.add("system", "001"); // 系统编码
        headers.add("usercode", "15253172037"); // 用户
        headers.add("password", "514576f58a89767b46c1b44767a08f77");
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        //销售出库单查询  ,"fbillflag":"4"
        //fbillflag(单据状态):1（删除）2（自由）3（签字）4（存货系统审核） ,"page_now":"1","page_size":"9999"
        String json = "{\"corp\":\"201\",\"date_begin\":\"2021-10-01\",\"date_end\":\"2021-10-31\"}";
        HttpEntity<String> formEntity = new HttpEntity<String>(json, headers);
        String url = "http://124.70.28.147:8088/u8cloud/api/ic/saleout/query";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
        //System.out.println("result:"+result);
        logger.info("销售出库单:"+result);

        Yfd yfd = restTemplate.postForEntity(url, formEntity, Yfd.class).getBody();
        JSONObject resultObject = JSON.parseObject(yfd.getData());
        JSONArray jsonArray = resultObject.getJSONArray("datas");
        JSONObject jsonObject;
        int size=0;
        if (jsonArray != null) {
            for (int i = 0; i < jsonArray.size(); i++) {
                jsonObject = jsonArray.getJSONObject(i);
                XsckdData.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", XsckdData.DatasBean.ParentvoBean.class);
                List<XsckdData.DatasBean.ChildrenvoBean> childrenvo = JSON.parseArray(jsonObject.get("childrenvo").toString(), XsckdData.DatasBean.ChildrenvoBean.class);
                size=size+childrenvo.size();
                for (XsckdData.DatasBean.ChildrenvoBean childrenvoBean : childrenvo) {
                    BtyPsd psd=new BtyPsd();
                    psd.setCdispatcherid(parentvo.getCdispatcherid());
                    psd.setDispatcherCode(parentvo.getDispatcher_code());
                    psd.setDispatcherName(parentvo.getDispatcher_name());
                    psd.setCdptid(parentvo.getCdptid());
                    psd.setDeptCode(parentvo.getDept_code());
                    psd.setDeptName(parentvo.getDept_name());
                    psd.setCoperatorid(parentvo.getCoperatorid());
                    psd.setOperatorCode(parentvo.getOperator_code());
                    psd.setOperatorName(parentvo.getOperator_name());
                    psd.setCwarehouseid(parentvo.getCwarehouseid());
                    psd.setWarehouseidCode(parentvo.getWarehouseid_code());
                    psd.setWarehouseidName(parentvo.getWarehouseid_name());
                    psd.setPkCalbody(parentvo.getPk_calbody());
                    psd.setCalbodyCode(parentvo.getCalbody_code());
                    psd.setCalbodyName(parentvo.getCalbody_name());
                    psd.setPkCorp(parentvo.getPk_corp());
                    psd.setCorpCode(parentvo.getCorp_code());
                    psd.setCorpName(parentvo.getCorp_name());
                    psd.setDaccountdate(parentvo.getDaccountdate());
                    psd.setTaccounttime(parentvo.getTaccounttime());
                    psd.setTmaketime(parentvo.getTmaketime());
                    psd.setCbilltypecode(parentvo.getCbilltypecode());
                    psd.setVnote(parentvo.getVnote());
                    psd.setVbillcode(parentvo.getVbillcode());
                    psd.setDbilldate(parentvo.getDbilldate());
                    psd.setCcustomerid(parentvo.getCcustomerid());
                    psd.setCustomerCode(parentvo.getCustomer_code());
                    psd.setCustomerName(parentvo.getCustomer_name());
                    psd.setBiztypeCode(parentvo.getBiztype_code());
                    psd.setBiztypeName(parentvo.getBiztype_name());

                    //childrenvo
                    psd.setCrowno(childrenvoBean.getCrowno());
                    psd.setCinventoryid(childrenvoBean.getCinventoryid());
                    psd.setNoutnum(childrenvoBean.getNoutnum());
                    psd.setNprice(childrenvoBean.getNprice());
                    psd.setNmny(childrenvoBean.getNmny());
                    psd.setDbizdate(childrenvoBean.getDbizdate());
                    psd.setCbodywarehouseid(childrenvoBean.getCbodywarehouseid());
                    psd.setBodywarehouseCode(childrenvoBean.getBodywarehouse_code());
                    psd.setBodywarehouseName(childrenvoBean.getBodywarehouse_name());
                    psd.setNshouldoutnum(childrenvoBean.getNshouldoutnum());
                    psd.setVuserdef4(childrenvoBean.getVuserdef4());
                    psd.setVuserdef5(childrenvoBean.getVuserdef5());
                    psd.setCvendorid(childrenvoBean.getCvendorid());
                    psd.setVendorCode(childrenvoBean.getVendor_code());
                    psd.setVendorName(childrenvoBean.getVendor_name());
                    psd.setCgeneralbid(childrenvoBean.getCgeneralbid());
                    psd.setCgeneralhid(childrenvoBean.getCgeneralhid());
                    psdService.save(psd);
                }
            }
            System.out.println("size:"+size);
        }
    }
    @Test
    public void pz(){
        String zdrq="2021-10-31";
        List<BtyElmsxfResult>list=elmsxfMapper.dmListByMdId();
        for (BtyElmsxfResult elmResult : list) {
            BigDecimal tbje=elmResult.getTbje();
            String bh=elmResult.getBh();
            String yaoma=elmResult.getYaoma();
            String mdid=elmResult.getMdid();
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
            headers.add("system", "001"); // 系统编码
            headers.add("usercode", "15253172037"); // 用户
            headers.add("password", "514576f58a89767b46c1b44767a08f77");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());

            StringBuilder sb=new StringBuilder();
            sb.append("{\n" +
                    "    \"voucher\":[\n" +
                    "        {\n" +
                    "            \"details\":[");

            //饿了么手续费凭证
            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":\""+tbje+"\",\n" +
                    "                    \"explanation\":\"饿了么手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"660305\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"2\",\n" +
                    "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                    "                        },\n" +
                    "\t\t\t\t\t\t{\n" +
                    "                            \"checktypecode\":\"7\",\n" +
                    "                            \"checkvaluecode\":\"0019\"\n" +//饿了么外卖辅助核算编码
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\""+tbje+"\",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"饿了么手续费\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"112212\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
            sb.append("            ],\n" +
                    "            \"pk_corp\":"+bh+",\n" +
                    "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                    "            \"pk_prepared\":\"15253172037\",\n" +
                    "            \"pk_vouchertype\":\"记账\",\n" +
                    "            \"prepareddate\":\""+zdrq+"\"\n" +
                    "        }\n" +
                    "    ]\n" +
                    "}");
            //System.out.println("sb:"+sb.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
            String url = "http://124.70.28.147:8089/u8cloud/api/gl/voucher/insert";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            System.out.println("result:"+result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取errcode对应的值
            String status = jo.get("status").getAsString();

            if(status.equals("falied")){
                String errormsg = jo.get("errormsg").getAsString();
                List<BtyElmsxf>list1=elmsxfMapper.selectList(new QueryWrapper<BtyElmsxf>().eq("mdid",mdid));
                if(list1.size()>0){
                    BtyElmsxfParam param1=new BtyElmsxfParam();
                    param1.setMdid(mdid);
                    param1.setErrormsg(errormsg);
                    elmsxfMapper.updateErrMsgByMdid(param1);
                }
                System.out.println("errormsg:"+errormsg);
            }else{
                List<BtyElmsxf>list1=elmsxfMapper.selectList(new QueryWrapper<BtyElmsxf>().eq("mdid",mdid));
                if(list1.size()>0){
                    BtyElmsxfParam param1=new BtyElmsxfParam();
                    param1.setMdid(mdid);
                    elmsxfMapper.updateByMdid(param1);
                }
                System.out.println("凭证导入成功！");
            }
        }
    }
    @Test
    public void yybb() {
            try {
                logger.info("====查询各店营业额并更新开始===start====");
                //String time = DateUtil.getYearstoday(new Date());
                String time = "2021-12-24";
                //String yesterday = DateUtil.getYesterDay4Oclock();
                String yesterday = "2021-12-24 04:00:00";
                //String today = DateUtil.getToday4Oclock();
               String today = "2021-12-25 04:00:00";
                Timestamp yesterdayTime = Timestamp.valueOf(yesterday);
                Timestamp todayTime = Timestamp.valueOf(today);
                List<BizResult> list = bizMapper.listMd(yesterdayTime, todayTime);
                for (BizResult bizResult : list) {
                    BigDecimal yye = bizResult.getYye();
                    BigDecimal yhje = bizResult.getYhje();
                    BigDecimal yysr = bizResult.getYysr();
                    BigDecimal yhk = new BigDecimal(0);
                    BigDecimal wx = new BigDecimal(0);
                    BigDecimal zfb = new BigDecimal(0);
                    BigDecimal mt = new BigDecimal(0);
                    BigDecimal mtmd = new BigDecimal(0);
                    BigDecimal hyk = new BigDecimal(0);
                    BigDecimal mtwm = BigDecimal.ZERO;
                    BigDecimal elm = BigDecimal.ZERO;
                    BigDecimal notIncome = BigDecimal.ZERO;
                    BigDecimal fss = new BigDecimal(0);
                    BigDecimal xj = new BigDecimal(0);
                    Integer shopId = bizResult.getRecTypeId();
                    String dm = bizResult.getRecType();
                    String yaoma="";
                    //通过店名获取妖码
                    if(ToolUtil.isNotEmpty(dm)){
                        BtyBrand brand=btyBrandMapper.selectOne(new QueryWrapper<BtyBrand>().eq("dm",dm));
                        if(ToolUtil.isNotEmpty(brand)){
                            yaoma=brand.getYaoma();
                        }
                    }
                    if(shopId==44432){
                    List<BizResult> listMd = bizMapper.listMdByShopId(shopId, yesterdayTime, todayTime);
                    for (BizResult result : listMd) {
                        notIncome = notIncome.add(result.getNotIncome());
                        fss = notIncome;
                        String payway = result.getPayway();
                        if (payway.contains("建行收款")) {
                            yhk = result.getIncome();
                        } else if (payway.contains("微信")) {
                            wx = wx.add(result.getIncome());
                        } else if (payway.contains("支付宝") | payway.contains("口碑团购")) {
                            zfb = zfb.add(result.getIncome());
                        } else if (payway.contains("美团团购")) {
                            mt = result.getIncome();
                        } else if (payway.contains("点评买单")) {
                            mtmd = result.getIncome();
                        } else if (payway.contains("会员卡（储值）") | payway.contains("会员卡储值线上")) {
                            hyk = hyk.add(result.getIncome());
                        } else if (payway.contains("美团外卖")) {
                            mtwm = mtwm.add(result.getIncome());
                        } else if (payway.contains("饿了么外卖")) {
                            elm = elm.add(result.getIncome());
                        } else if (payway.contains("人民币")) {
                            xj = result.getIncome();
                        }
                    }
                    Yybb yybb = new Yybb();
                    yybb.setYyr(time);
                    yybb.setDianming(dm);
                    yybb.setYye(yye);
                    yybb.setYhje(yhje);
                    yybb.setYysr(yysr);
                    yybb.setYhk(yhk);
                    yybb.setWx(wx);
                    yybb.setZfb(zfb);
                    yybb.setMt(mt);
                    yybb.setMtmd(mtmd);
                    yybb.setMtwm(mtwm);
                    yybb.setElm(elm);
                    yybb.setHyk(hyk);
                    yybb.setFss(fss);
                    yybb.setXj(xj);
                    if(ToolUtil.isNotEmpty(yaoma)){
                        yybb.setYaoma(yaoma);
                    }
                      yybbService.save(yybb);
                    }
                }
                logger.info("====查询各店营业额并更新完成===end====");
            } catch (Exception e) {
                String err = e.getMessage();
                String data = "查询各店营业额并更新出现异常！";
                JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
                String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                logger.error("查询各店营业额并更新出现异常", e);
                e.printStackTrace();
            }
    }
    @Test
    public void readTxt() {
            BufferedReader reader = null;
            try {
                logger.info("====更新会员卡实际数据开始====");
                String yesterDayDate = DateUtil.getYesterDayDate();
                //String yesterDayDate = "2021-12-08";
                RestTemplate restTemplate = new RestTemplate();
                String publicKey = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDwteCbSQgiIUwMZgX6Q5cGLCwH0i9Ou7bveU8JGuJcf416bVLpBZA6Hkdu47mxUETY3Bf4++yQ3khU0Il8JvtDp84AbAPEQI+qIoTF4Zm4Yytux6XLG8IYQWx1BBXNeDuuBl3d6q6cmgDz2zDX4IkF/HmAjBJuw3jCDMHwn/ZuNQIDAQAB";
                // 调用方id
                Integer productId = 1000002886;
                // 版本号
                String version = "1.0.0";
                // 业务参数封装并加密
                JSONObject obj = new JSONObject();
                obj.put("companyId", 1000002886);
                //获取消费类型的数据
                List<Integer> list = new ArrayList<Integer>();
                //获取消费类型的数据
                list.add(1);
                //获取充值类型的数据
                list.add(2);
                //获取撤销充值类型的数据
                list.add(29);
                //获取撤销消费类型的数据
                list.add(30);
                obj.put("tradeTypeIds", list);
                String time = DateUtil.getStampNow();
                String startTime = DateUtil.getYesterDayDate() + " 00:00:00";
                String endTime = DateUtil.getYesterDayDate() + " 23:59:59";

//                String startTime = "2021-12-08"+ " 00:00:00";
//                String endTime = "2021-12-08"+ " 23:59:59";
                obj.put("queryId", time);
                obj.put("startTime", startTime);
                obj.put("endTime", endTime);
                String callbackUrl = "https://rs.bantianyaozg.com";
                //base64加密
                String callbackUrls = Base64.encode(callbackUrl.getBytes());
                System.out.println();
                obj.put("callbackUrl", callbackUrls);
                String sign = RsaUtil.encryptByPublicKey(obj.toJSONString(), publicKey);
                // 参数拼接在url后面
                String url = "https://scrm.wuuxiang.com/crm7api/api/trade/biglist.do?sign=" + sign + "&" + "productId=" + productId + "&" + "version=" + version;

                System.out.println("url:" + url);
                String result = restTemplate.getForObject(url, String.class);
                System.out.println("result:" + result);
                JsonParser jp = new JsonParser();
                //将json字符串转化成json对象
                JsonObject jo = jp.parse(result).getAsJsonObject();
                String downloadUrl = jo.get("rpData").getAsJsonObject().get("url") == null ? "" : jo.get("rpData").getAsJsonObject().get("url").toString();
                String downloadUrls = "";

                if (ToolUtil.isEmpty(downloadUrl)) {
                    String searchStatus;
                    String queryId = jo.get("rpData").getAsJsonObject().get("queryId").toString();
                    JSONObject objs = new JSONObject();
                    objs.put("companyId", 1000002886);
                    objs.put("queryId", queryId);
                    objs.put("tradeTypeIds", list);
                    objs.put("startTime", startTime);
                    objs.put("endTime", endTime);
                    //base64加密
                    objs.put("callbackUrl", callbackUrls);
                    String sign1 = RsaUtil.encryptByPublicKey(objs.toJSONString(), publicKey);
                    do {
                        // 参数拼接在url后面
                        String url1 = "https://scrm.wuuxiang.com/crm7api/api/trade/biglist.do?sign=" + sign1 + "&" + "productId=" + productId + "&" + "version=" + version;
                        System.out.println("url1:" + url1);
                        String results = restTemplate.getForObject(url1, String.class);
                        JsonObject jos = jp.parse(results).getAsJsonObject();
                        searchStatus = jos.get("rpData").getAsJsonObject().get("searchStatus") == null ? "" : jos.get("rpData").getAsJsonObject().get("searchStatus").toString();
                        System.out.println("results:" + results);
                        System.out.println("searchStatus:" + searchStatus);
                        downloadUrls = jos.get("rpData").getAsJsonObject().get("url") == null ? "" : jos.get("rpData").getAsJsonObject().get("url").toString();
                    } while (searchStatus.equals("0"));
                }
                System.out.println("downloadUrl:" + downloadUrls);
                downloadUrls = downloadUrls.replace("\"", "").replace("\\", "");
                String fileName = downloadUrls.substring(downloadUrls.lastIndexOf("/"));     //为下载的文件命名
                String filePath = "D:/hyksj";      //保存目录
                int lastIndexof = downloadUrls.lastIndexOf("/");
                String fileNames = downloadUrls.substring(lastIndexof + 1);
                System.out.println("fileName:" + fileNames);
                String newFileName = URLEncoder.encode(fileNames, "utf-8");
                String subUrl = downloadUrls.substring(0, lastIndexof + 1);
                String newUrl = subUrl + newFileName;
                System.out.println("downloadUrls222:" + newUrl);
                File file = saveUrlAs(newUrl, filePath + fileName, "GET");
                System.out.println("file:" + file);
                //解压文件
                File zipFile = new File("D:\\hyksj\\" + fileName + "\\" + newFileName + "");

                String path = "D:/hyksj" + fileName + "/";
                System.out.println("path:" + path);
                String outPath = unZipFiles(zipFile, path);
                if (outPath.contains("zip")) {
                    try {
                        unZipFiles(outPath, path);
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }

                String ss = fileName.replace("zip", "txt");
                String fileNamess = "D:\\hyksj\\" + fileName + "\\" + ss + "";
                File files = new File(fileNamess);

                InputStreamReader isr = new InputStreamReader(new FileInputStream(files), "UTF-8");
                //reader = new BufferedReader(new FileReader(files));
                reader = new BufferedReader(isr);
                String tempStr;
                while ((tempStr = reader.readLine()) != null) {
                    HykData hykData = new HykData();
                    JSONObject jsonObject = JSONObject.parseObject(tempStr);
                    hykData.setXfShopName(jsonObject.getString("xfShopName"));
                    hykData.setTradeTypeId(jsonObject.getString("tradeTypeId"));
                    hykData.setTsTypeName(jsonObject.getString("tsTypeName"));
                    hykData.setCreateTime(jsonObject.getString("createTime"));
                    ExpandInfo expandInfo = jsonObject.getObject("expandInfo", ExpandInfo.class);
                    BtyHyk hyk = new BtyHyk();
                    hyk.setId(UUIDUtils.getId());
                    hyk.setDm(hykData.getXfShopName());
                    if (ToolUtil.isNotEmpty(expandInfo)) {
                        if (ToolUtil.isNotEmpty(expandInfo.getConsumeCash())) {
                            hyk.setXfbj(expandInfo.getConsumeCash() == null ? BigDecimal.ZERO : expandInfo.getConsumeCash());
                        }
                    }
                    if (hykData.getTradeTypeId().equals("2") | hykData.getTradeTypeId().equals("29") && ToolUtil.isNotEmpty(expandInfo)) {
                        hyk.setCzje(expandInfo.getRechargeAmount() == null ? BigDecimal.ZERO : expandInfo.getRechargeAmount());
                    }
                    if (hykData.getTradeTypeId().equals("30") && ToolUtil.isNotEmpty(expandInfo)) {
                        hyk.setXfbj(expandInfo.getConsumeCash() == null ? BigDecimal.ZERO : expandInfo.getConsumeCash().multiply(new BigDecimal(-1)));
                    }
                    hyk.setJylx(hykData.getTradeTypeId());
                    hyk.setCzlxmc(hykData.getTsTypeName());
                    hyk.setJysj(hykData.getCreateTime());
                    hyk.setYyr(yesterDayDate);
                    hykService.save(hyk);
                }
                //获取bty_hyk表中的数据,更新会员卡消费本金金到yybb表中hyksj字段
                BtyHykParam param = new BtyHykParam();
                param.setYyr(yesterDayDate);
                List<BtyHykResult> list1 = hykService.listMdxfbj(param);
                if (list1.size() > 0) {
                    for (BtyHykResult btyHykResult : list1) {
                        String dm = btyHykResult.getDm();
                        BigDecimal xfbj = btyHykResult.getXfbj();
                        Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                        if (ToolUtil.isNotEmpty(yybb)) {
                            yybb.setHyksj(xfbj);
                            yybbService.updateById(yybb);
                        }
                    }
                }

                logger.info("====更新会员卡实际数据结束====");
            } catch (Exception e) {
                String err = e.getMessage();
                String data = "更新会员卡实际数据出现异常！";
                JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
                String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                logger.info("====更新会员卡实际数据出现异常====" + e);
                e.printStackTrace();
            } finally {
                if (reader != null) {
                    try {
                        reader.close();
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
    }
    @Test
    public  void hyksjs(){
        logger.info("====更新会员卡实际数据开始====");
        String yesterDayDate = DateUtil.getYesterDayDate();
        //获取bty_hyk表中的数据,更新会员卡消费本金金到yybb表中hyksj字段
        BtyHykParam param = new BtyHykParam();
        param.setYyr(yesterDayDate);
        List<BtyHykResult> list1 = hykService.listMdxfbj(param);
        if (list1.size() > 0) {
            for (BtyHykResult btyHykResult : list1) {
                String dm = btyHykResult.getDm();
                BigDecimal xfbj = btyHykResult.getXfbj();
                Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                if (ToolUtil.isNotEmpty(yybb)) {
                    yybb.setHyksj(xfbj);
                    yybbService.updateById(yybb);
                }
            }
        }
        logger.info("====更新会员卡实际数据结束====");
    }

    @Test
    public void salesDataNhs() {
        try {
            logger.info("===更新南湖数据开始...");
            String time = DateUtil.subtractTime(new Date(), -300000);
            System.out.println("time:" + time);
            String urls = "https://cysms.wuuxiang.com/api/auth/accesstoken?appid=e30659b3b3dc4ec5bede0f8100b402d1&accessid=1a2aba829e7841e3bddc383f28c40334&response_type=token";
            RestTemplate restTemplate = new RestTemplate();
            JSONObject jsonss = new JSONObject();
            HttpEntity<String> formEntityss = new HttpEntity<String>(jsonss.toString());
            String results = restTemplate.postForEntity(urls, formEntityss, String.class).getBody();
            //System.out.println("result:" + results);
            JSONObject jsonObject = JSONObject.parseObject(results);
            String accessToken = jsonObject.get("access_token").toString();
            System.out.println("accessToken:" + accessToken);
            //String timeBegin = DateUtil.getNow();
            String urlss = "https://cysms.wuuxiang.com/api/datatransfer/getserialdata?centerId=13289&shopId=83756&settleDate=2021-11-18&&pageNo=1&pageSize=50&dateType=2";
            HttpHeaders header = new HttpHeaders();
            header.add("access_token", accessToken);
            header.add("accessid", "1a2aba829e7841e3bddc383f28c40334");
            header.add("granttype", "client");

            HttpEntity<String> formEntitys = new HttpEntity<>(header);
            String resultss = restTemplate.postForEntity(urlss, formEntitys, String.class).getBody();
            logger.info("南湖" + time + "result:" + resultss);
            Tc tc = restTemplate.postForEntity(urlss, formEntitys, Tc.class).getBody();
           // BigDecimal lastTotal = BigDecimal.ZERO;
            // System.out.println("results:"+tcss.getData().getShopBillList().get(0).getBillList().size());
            //System.out.println("results:" + tcss.getData().getShopBillList().get(0).getBillList().size());

            if (tc.getData().getBillList().size() > 0) {
                List<Tc.DataBean.BillListBean> list = tc.getData().getBillList();
                for (Tc.DataBean.BillListBean billList : list) {
                    // BigDecimal yye= new BigDecimal(billList.getLast_total().toString());
                    // int num=yye.compareTo(BigDecimal.ZERO);
                    if (billList.getState().equals("1")) {
                        //String jssj=billList.getSettle_time().toString();
                        String jslsbh = billList.getBs_code();
                        List<BtySsyye> lists = ssyyeService.list(new QueryWrapper<BtySsyye>().eq("jslsbh", jslsbh));
                        System.out.println("lists.size:" + lists.size());
                        if (lists.size() <= 0) {
                            BtySsyye ssyye = new BtySsyye();
                            ssyye.setId(UUIDUtils.getId());
                            ssyye.setDm(billList.getShop_name());
                            ssyye.setYye(new BigDecimal(billList.getLast_total().toString()));
                            ssyye.setJssj(billList.getSettle_time().toString());
                            ssyye.setJslsbh(billList.getBs_code());
                            ssyyeService.save(ssyye);
                        }

                        //lastTotal = lastTotal.add(new BigDecimal(billList.getLast_total().toString()));
                    }
                }
                //System.out.println("销售额：" + lastTotal);
                //String state=tcss.getData().getShopBillList().get(0).getBillList()
            }


        } catch (Exception e) {
            //logger.error("更新南湖销售数据 出现异常", e);
            e.printStackTrace();
        }
    }
    @Test
    public void nhs() throws Exception {
        RestTemplate restTemplate=new RestTemplate();
        String money="0";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
        String now = sdf.format(new Date());
        String nowDate = DateUtil.getStampNow();
        logger.info("南湖销售额：" + money);
        String str[] = {};
        Map map = new HashMap();
        map.put("cardBank", "");
        map.put("cardNumber", "");
        map.put("discountAmt", 0);
        map.put("payAmt", money);
        map.put("paymentMethod", "CH");
        map.put("time", nowDate);
        map.put("value", money);
        List<Map<String, Object>> payList = new ArrayList<>();
        payList.add(map);

        //RestTemplate restTemplate = new RestTemplate();
        JSONObject dataJson = new JSONObject();
        //收银员编号
        dataJson.put("cashierId", "20122tvaa922n0101");
        //店铺验证密钥
        dataJson.put("checkCode", "p88888888");
        //备注
        dataJson.put("comments", "comments");
        dataJson.put("itemList", str);
        //商场编号
        dataJson.put("mall", "20122");
        dataJson.put("mobile", "");
        //订单号
        dataJson.put("orderId", nowDate);
        System.out.println("订单号orderId:" + nowDate);
        dataJson.put("payList", payList);
        dataJson.put("refOrderId", "refOrderId");
        //店铺编号
        dataJson.put("store", "TVAA922N01");
        //收银机编号
        dataJson.put("tillId", "01");
        dataJson.put("time", nowDate);
        //订单总金额
        dataJson.put("totalAmt", money);
        //销售：SALE 退货：ONLINEREFUND
        dataJson.put("type", "SALE");
        //dataJson.put("type", "ONLINEREFUND");
        //来源 01 店铺 02数据采集盒子
        dataJson.put("source", "01");
        //合作伙伴身份标识
        String Partner_ID = "70000029";
        //调用的API版本号
        String Api_Version = "1.0.1";
        //被调用API的应用编码
        String App_Sub_ID = "10000187223FL";
        //API调用的API编码
        String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
        //API调用方授权令牌
        String App_Token = "eebc2d353cc149629193e555a4560cbd";
        //被调用API的应用编码
        String App_Pub_ID = "10000187223RL";
        //合作伙伴系统编码
        String Sys_ID = "100001872";

        //拼接待签名字符串
        String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
        //生成签名获取sign的值
        String sign = Md5Util.md5(strs);
        System.out.println("strs:" + strs);
        System.out.println("sign:" + sign);

        JSONObject contentJson = new JSONObject();
        contentJson.put("Partner_ID", Partner_ID);
        contentJson.put("Api_Version", Api_Version);
        contentJson.put("App_Sub_ID", App_Sub_ID);
        //响应格式,默认为json格式，可选值：xml或json
        contentJson.put("Format", "json");
        //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
        contentJson.put("Time_Stamp", now);
        contentJson.put("Api_ID", Api_ID);
        contentJson.put("App_Token", App_Token);
        contentJson.put("App_Pub_ID", App_Pub_ID);
        //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
        contentJson.put("Sign_Method", "md5");
        //服务请求的签名字符串
        contentJson.put("Sign", sign);
        contentJson.put("Sys_ID", Sys_ID);
        JSONObject jsons = new JSONObject();
        jsons.put("REQUEST_DATA", dataJson);
        jsons.put("HRT_ATTRS", contentJson);

        JSONObject json = new JSONObject();
        json.put("REQUEST", jsons);
        System.out.println("REQUEST_DATA:" + dataJson);
        System.out.println("json:" + json);
        HttpHeaders headers = new HttpHeaders();
        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
        headers.setContentType(type);
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());
        HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
         String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
        //String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
        String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
        System.out.println("result:" + result);
        JsonParser jp = new JsonParser();
        //将json字符串转化成json对象
        JsonObject jo = jp.parse(result).getAsJsonObject();
        //获取errcode对应的值
        String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
        String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
        if (errcode.equals("0000")) {
            System.out.println("南湖销售数据更新成功！");
            logger.info("===南湖销售数据更新成功！");
        } else {
            System.out.println("错误码：" + errcode + "错误信息:" + errmsg);
            logger.info("错误码：" + errcode + "错误信息:" + errmsg);
        }
    }
     @Test
    public void elmTest(){
        //导入成功之后更新饿了么结算金额到yybb中
         elmMapper.updateYybb();

//        BtyElmParam param=new BtyElmParam();
//        List<BtyElmResult>list=elmMapper.elmList(param);
//        for (BtyElmResult btyElmResult : list) {
//            String dm=btyElmResult.getDm();
//            String yyr=btyElmResult.getZdrq();
//            BigDecimal jsje=btyElmResult.getJsje();
//            Yybb yybb=yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming",dm).eq("yyr",yyr));
//            if(ToolUtil.isNotEmpty(yybb)){
//                yybb.setElmsj(jsje);
//                yybbService.updateById(yybb);
////                if(flag==true){
////                    BtyElmParam param1=new BtyElmParam();
////                    param1.setDm(dm);
////                    List<BtyElmResult> lists=elmMapper.getMdidByDm(param1);
////                    if(lists.size()>0){
////                        String mdid=lists.get(0).getMdid();
////                        param1.setMdid(mdid);
////                        elmMapper.updateByMdid(param1);
////                    }
////                }
//            }
//        }
    }
    @Test
    public  void pz111(){
            //导入成功之后按大区生成凭证
            String zdrq="2021-11-23";
            String bh="201";
            List<BtyShdkmxResult> list=shdkmxMapper.dkmxList();
            String yhk=list.get(0).getYhk();
            for (BtyShdkmxResult mxResult : list) {
                BigDecimal je = mxResult.getJe();
                String ksbm ="";
                String dm = mxResult.getDm();
                //根据店名查询客商辅助核算编码
                String json = "{\"custname\":\""+dm+"\"}";
                RestTemplate restTemplate = new RestTemplate();
                HttpHeaders headers = new HttpHeaders();
                MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
                headers.setContentType(type);
                headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
                headers.add("system", "001"); // 系统编码
                headers.add("usercode", "15253172037"); // 用户
                headers.add("password", "514576f58a89767b46c1b44767a08f77");
                headers.add("Accept", MediaType.APPLICATION_JSON.toString());

                HttpEntity<String> formEntitys = new HttpEntity<String>(json, headers);
                String urls = "http://124.70.28.147:8089/u8cloud/api/uapbd/custdoc/query";

                Yfd yfd = restTemplate.postForEntity(urls, formEntitys, Yfd.class).getBody();
                JSONObject resultObject = JSON.parseObject(yfd.getData());
                JSONArray jsonArray = resultObject.getJSONArray("datas");
                JSONObject jsonObject;
                if (jsonArray != null) {
                 for (int i = 0; i < jsonArray.size(); i++) {
                    jsonObject = jsonArray.getJSONObject(0);
                    Ksda.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", Ksda.DatasBean.ParentvoBean.class);
                    ksbm=parentvo.getCustcode();
                   }
                }

                StringBuilder sb=new StringBuilder();
                sb.append("{\n" +
                        "    \"voucher\":[\n" +
                        "        {\n" +
                        "            \"details\":[");

                sb.append("                {\n" +
                        "                    \"ass\":[\n" +
                        "                        {\n" +
                        "                            \"checktypecode\":\"96\",\n" +
                        "                            \"checkvaluecode\":"+yhk+"\n" +//银行账户辅助核算
                        "                        }\n" +
                        "                    ],\n" +
                        "                    \"creditamount\":\"\",\n" +
                        "                    \"debitamount\":\""+je+"\",\n" +
                        "                    \"explanation\":\"门店货款\",\n" +
                        "                    \"localcreditamount\":\"\",\n" +
                        "                    \"localdebitamount\":\"\",\n" +
                        "                    \"pk_accsubj\":\"100203\",\n" +
                        "                    \"pk_currtype\":\"CNY\"\n" +
                        "                }," +
                        "{\n" +
                        "\t\t\t\t\"ass\":[\n" +
                        "                        {\n" +
                        "                            \"checktypecode\":\"73\",\n" +
                        "                            \"checkvaluecode\":'"+ksbm+"'\n" +//客商辅助核算编码
                        "                        },\n" +
                        "                    ],\n" +
                        "                    \"creditamount\":\""+je+"\",\n" +
                        "                    \"creditquantity\":\"\",\n" +
                        "                    \"debitamount\":\"\",\n" +
                        "                    \"debitquantity\":\"\",\n" +
                        "                    \"detailindex\":\"\",\n" +
                        "                    \"excrate1\":\"\",\n" +
                        "                    \"explanation\":\"门店货款\",\n" +
                        "                    \"localcreditamount\":\"\",\n" +
                        "                    \"localdebitamount\":\"\",\n" +
                        "                    \"pk_accsubj\":\"1122\",\n" +
                        "                    \"pk_currtype\":\"CNY\",\n" +
                        "                    \"price\":\"\"\n" +
                        "                },\n");
                sb.append("            ],\n" +
                        "            \"pk_corp\":"+bh+",\n" +
                        "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                        "            \"pk_prepared\":\"15253172037\",\n" +
                        "            \"pk_vouchertype\":\"记账\",\n" +
                        "            \"prepareddate\":\""+zdrq+"\"\n" +
                        "        }\n" +
                        "    ]\n" +
                        "}");

                System.out.println("sb:"+sb.toString());
                HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
                String url = "http://124.70.28.147:8089/u8cloud/api/gl/voucher/insert";
                String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
                System.out.println("result:"+result);
                JsonParser jp = new JsonParser();
                //将json字符串转化成json对象
                JsonObject jo = jp.parse(result).getAsJsonObject();
                //获取status对应的值
                String status = jo.get("status").getAsString();

                if (status.equals("falied")) {
                    String errormsg = jo.get("errormsg").getAsString();
                    BtyShdkmx shdkmx=shdkmxMapper.selectOne(new QueryWrapper<BtyShdkmx>().eq("dm",dm));
                    if(ToolUtil.isNotEmpty(shdkmx)){
                        shdkmx.setErrormsg(errormsg);
                        shdkmxMapper.updateById(shdkmx);
                    }
                    System.out.println("errormsg:"+errormsg);
                } else {
                    BtyShdkmx shdkmx=shdkmxMapper.selectOne(new QueryWrapper<BtyShdkmx>().eq("dm",dm));
                    if(ToolUtil.isNotEmpty(shdkmx)){
                        shdkmx.setFlag(1);
                        shdkmxMapper.updateById(shdkmx);
                    }

                    System.out.println("凭证生成成功！");
                }
            }

    }

    @Test
    public void testBankTxt() {
            try {
                logger.info("====更新建行收款开始====");
                //构造请求报文
                SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
                String number = df.format(new Date());
                StringBuilder soap = new StringBuilder();
                String date = DateUtil.getYesterDay();
                //System.out.println("date:" + date);
                soap.append("<?xml version=\"1.0\" encoding=\"GB18030\" standalone=\"yes\" ?>");
                soap.append("<TX>");
                soap.append("<REQUEST_SN>" + number + "</REQUEST_SN>");
                soap.append("<CUST_ID>105003958129374</CUST_ID>");
                soap.append("<USER_ID>105003958129374-001</USER_ID>");
                soap.append("<PASSWORD>bty123456</PASSWORD>");
                soap.append("<TX_CODE>5W1005</TX_CODE>");
                soap.append("<LANGUAGE>CN</LANGUAGE> ");
                soap.append("<TX_INFO> ");
                soap.append("<DATE>" + date + "</DATE> ");
                soap.append("<KIND>1</KIND> ");
                soap.append("<FILETYPE>1</FILETYPE> ");
                soap.append("<Mrch_No>all</Mrch_No> ");
                soap.append("<GROUP_FLAG>1</GROUP_FLAG> ");
                soap.append("</TX_INFO>");
                soap.append("</TX>");

                String requestSoap = soap.toString();
                System.out.println("requestSoap:" + requestSoap);
                //服务地址(将url替换成自己项目的地址)
                String ipAdress = "127.0.0.1";
                int nPort = 12345;
                String sRequest = soap.toString();
                String result = SoapUtil.sendHttpRequest(ipAdress, nPort, sRequest);
                System.out.println("result:" + result);
                //字符串转XML
                org.dom4j.Document document = DocumentHelper.parseText(result);
                //获取文档根节点
                Element root = document.getRootElement();
                //输出根标签的名字
                System.out.println(root.getName());
                String fileName = "";
                //获得指定节点下面的子节点
                Element contactElem = root.element("TX_INFO");//首先要知道自己要操作的节点。
                List<Element> contactList = contactElem.elements();
                for (Element e : contactList) {
                    if (e.getName().equals("FILE_NAME")) {
                        fileName = e.getStringValue();
                        System.out.println(e.getStringValue());
                    }
                    //System.out.println(e.getName());
                }
                System.out.println("fileName:" + fileName);
                //根据文件名称下载建行对账单
                testBankTxtDownload(fileName);
            } catch (Exception e) {
                String err = e.getMessage();
                String data = "更新建行收款出现异常！" + e;
                JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
                String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                logger.info("===更新建行收款出现异常===" + e);
                e.printStackTrace();
            }
    }

    public void testBankTxtDownload(String fileName) {
        try {
            //构造请求报文
            SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
            String number = df.format(new Date());
            StringBuilder soap = new StringBuilder();
            soap.append("<?xml version=\"1.0\" encoding=\"GB18030\" standalone=\"yes\" ?>");
            soap.append("<TX>");
            soap.append("<REQUEST_SN>" + number + "</REQUEST_SN>");
            soap.append("<CUST_ID>105003958129374</CUST_ID>");
            soap.append("<USER_ID>105003958129374-001</USER_ID>");
            soap.append("<PASSWORD>bty123456</PASSWORD>");
            soap.append("<TX_CODE>6W0111</TX_CODE>");
            soap.append("<LANGUAGE>CN</LANGUAGE> ");
            soap.append("<TX_INFO> ");
            soap.append("<SOURCE>" + fileName + "</SOURCE> ");
            soap.append("<FILEPATH>merchant/shls</FILEPATH> ");
            soap.append("<LOCAL_REMOTE>0</LOCAL_REMOTE> ");
            soap.append("</TX_INFO>");
            soap.append("</TX>");
            String requestSoap = soap.toString();
            System.out.println("requestSoap:" + requestSoap);
            //服务地址(将url替换成自己项目的地址)
            String ipAdress = "127.0.0.1";
            int nPort = 12345;
            String sRequest = soap.toString();
            String result = SoapUtil.sendHttpRequest(ipAdress, nPort, sRequest);
            //String fileName="SHOP.105003958129374.20210427.20210427.20210428130142637.AbUG.zip";
            //String result ="<?xml version=\"1.0\" encoding=\"GB18030\"?><TX><REQUEST_SN>20210429104914</REQUEST_SN><CUST_ID>105003958129374</CUST_ID><TX_CODE>6W0111</TX_CODE><RETURN_CODE>000000</RETURN_CODE><RETURN_MSG>下载文件成功</RETURN_MSG><LANGUAGE>CN</LANGUAGE></TX>";
            System.out.println("result:" + result);
            String returnCode = "";
            //字符串转XML
            org.dom4j.Document document = DocumentHelper.parseText(result);
            //获取文档根节点
            Element root = document.getRootElement();
            //输出根标签的名字
            System.out.println(root.getName());
            //获得指定节点下面的子节点
            Element contactElem = root.element("RETURN_CODE");
            //首先要知道自己要操作的节点。
            returnCode = contactElem.getStringValue();
            //文件下载成功之后解压zip文件中的excel
            if (returnCode.equals("000000")) {
                //解压文件
                File zipFile = new File("G:\\CCB_EBSClient_B2C4FileCert_V5.9.3_Build20190827\\download\\" + fileName + "");
                String path = "G:/CCB_EBSClient_B2C4FileCert_V5.9.3_Build20190827/download/";
                String outPath = unZipFiles(zipFile, path);
                if (outPath.contains("zip")) {
                    unZipFiles(outPath, path);
                }
                logger.info("=======" + fileName + "解压成功========");
            }
            //readExcel();
            readJhTxt();
        } catch (Exception e) {
            String err = e.getMessage();
            String data = "更新建行收款出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.info("=======更新收款出现异常========" + e);
            e.printStackTrace();
        }
    }

    public void readJhTxt() {
        try {
            //读取txt中的数据存到bank_jhsk表中
            String date = DateUtil.getYesterDay();
            File file = new File("G:/CCB_EBSClient_B2C4FileCert_V5.9.3_Build20190827/download/SHOP.105003958129374." + date + ".det (Group Summary Statement).txt");
            BufferedReader reader = new BufferedReader(new FileReader(file));
            InputStreamReader isr = new InputStreamReader(new FileInputStream(file), "UTF-8");
            reader = new BufferedReader(isr);
            String lineTxt;
            reader.readLine();//忽略第一行标题
            BankTest bankTest = new BankTest();
            while ((lineTxt = reader.readLine()) != null) {
                String[] s = lineTxt.split("\\|");
                //System.out.println("length:"+s.length);
                //System.out.println("lineTxt:"+lineTxt);
                String jyje = s[14];
                String ddbh = s[19];
                String zdh = s[1];
                String jyrq = s[5];
                String jysj = s[6];
                String zfkh = s[18];
                String cjbs = s[7];
                String shgtdm = s[20];
                String sxf = s[12];
                if (jyje.contains(".")) {
                    if (ToolUtil.isNotEmpty(ddbh)) {
                        bankTest.setId(UUIDUtils.getId());
                        bankTest.setDdbh(ddbh);
                        bankTest.setZdh(zdh);
                        bankTest.setJyrq(jyrq);
                        bankTest.setJysj(jysj);
                        bankTest.setZfkh(zfkh);
                        bankTest.setJyje(jyje);
                        bankTest.setCjbs(cjbs);
                        bankTest.setShgtdm(shgtdm);
                        bankTest.setSxf(sxf);
                        bankTestService.save(bankTest);
                    }
                }
            }
            logger.info("====保存建行收款数据完成====");
            //获取bank_jhsk表中的数据,更新建行收款金额到yybb中
            String yesterdayDate = DateUtil.getYesterDayDate();
            //String yesterdayDate ="2021-08-14";
            BankTestParam param = new BankTestParam();
            param.setJyrq(yesterdayDate);
            List<BankTestResult> list = bankTestService.listMdye(param);
            for (BankTestResult bankTestResult : list) {
                String dm = bankTestResult.getDm();
                BigDecimal je = bankTestResult.getJyje();
                BigDecimal sxfs = bankTestResult.getYhksxf();
                Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterdayDate));
                if (ToolUtil.isNotEmpty(yybb)) {
                    yybb.setYhksj(je);
                    yybb.setYhksxf(sxfs);
                    yybbService.updateById(yybb);
                }

            }
        } catch (Exception e) {
            String err = e.getMessage();
            String data = "更新建行收款出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.info("====更新建行收款出现异常====" + e);
            e.printStackTrace();
            e.printStackTrace();
        }
        logger.info("====更新建行收款结束====");

    }
    @Test
    public void hyksj(){
        //获取bty_hyk表中的数据,更新会员卡消费本金金到yybb表中hyksj字段
        BtyHykParam param = new BtyHykParam();
        String yesterDayDate = "2021-12-18";
        //String yesterDayDate = DateUtil.getYesterDayDate();
        param.setYyr(yesterDayDate);
        List<BtyHykResult> list1 = hykService.listMdxfbj(param);
        if (list1.size() > 0) {
            for (BtyHykResult btyHykResult : list1) {
                String dm = btyHykResult.getDm();
                BigDecimal xfbj = btyHykResult.getXfbj();
                Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                if (ToolUtil.isNotEmpty(yybb)&&dm.equals("半天妖江苏常州九洲新世界店")) {
                    yybb.setHyksj(xfbj);
                    yybbService.updateById(yybb);
                }
            }
        }
    }
    @Test
    public void jhsk(){
        //获取bank_jhsk表中的数据,更新建行收款金额到yybb中
        //String yesterdayDate = DateUtil.getYesterDayDate();
        String yesterdayDate ="2021-12-18";
        BankTestParam param = new BankTestParam();
        param.setJyrq(yesterdayDate);
        List<BankTestResult> list = bankTestService.listMdye(param);
        for (BankTestResult bankTestResult : list) {
            String dm = bankTestResult.getDm();
            BigDecimal je = bankTestResult.getJyje();
            BigDecimal sxfs = bankTestResult.getYhksxf();
            Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterdayDate));
            if (ToolUtil.isNotEmpty(yybb)&&dm.equals("半天妖江苏常州九洲新世界店")) {
                yybb.setYhksj(je);
                yybb.setYhksxf(sxfs);
                yybbService.updateById(yybb);
            }

        }
    }
    @Test
    public void mdhkpz(){
        String bh="201";
        List<BtyShdkmxResult> list=shdkmxMapper.dkmxList();
        //String yhk=list.get(0).getYhk();
       // for (BtyShdkmxResult mxResult : list) {
//            BigDecimal je = mxResult.getJe();
            String ksbm ="";
//            String dm = mxResult.getDm();
//            String zdrq=mxResult.getZdrq();
//            String yhk=mxResult.getYhk();
        //String dm="东营广饶博兴啤酒直通"; //博兴啤酒直通
        String dm="博兴啤酒直通"; //博兴啤酒直通
            //根据店名查询客商辅助核算编码
            String json = "{\"custname\":\""+dm+"\"}";
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
            headers.add("system", "001"); // 系统编码
            headers.add("usercode", "15253172037"); // 用户
            headers.add("password", "514576f58a89767b46c1b44767a08f77");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());

            HttpEntity<String> formEntitys = new HttpEntity<String>(json, headers);
            String urls = "http://124.70.28.147:8088/u8cloud/api/uapbd/custdoc/query";

            Yfd yfd = restTemplate.postForEntity(urls, formEntitys, Yfd.class).getBody();
            String result = restTemplate.postForEntity(urls, formEntitys, String.class).getBody();
            System.out.println("result:"+result);
            JSONObject resultObject = JSON.parseObject(yfd.getData());
            JSONArray jsonArray = resultObject.getJSONArray("datas");
            JSONObject jsonObject;
            if (jsonArray != null) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    jsonObject = jsonArray.getJSONObject(0);
                    Ksda.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", Ksda.DatasBean.ParentvoBean.class);
                    ksbm=parentvo.getCustcode();
                    System.out.println("ksbm:"+ksbm);
                }
            }

//            StringBuilder sb=new StringBuilder();
//            sb.append("{\n" +
//                    "    \"voucher\":[\n" +
//                    "        {\n" +
//                    "            \"details\":[");
//
//            sb.append("                {\n" +
//                    "                    \"ass\":[\n" +
//                    "                        {\n" +
//                    "                            \"checktypecode\":\"96\",\n" +
//                    "                            \"checkvaluecode\":"+yhk+"\n" +//银行账户辅助核算
//                    "                        }\n" +
//                    "                    ],\n" +
//                    "                    \"creditamount\":\"\",\n" +
//                    "                    \"debitamount\":\""+je+"\",\n" +
//                    "                    \"explanation\":\"门店货款\",\n" +
//                    "                    \"localcreditamount\":\"\",\n" +
//                    "                    \"localdebitamount\":\"\",\n" +
//                    "                    \"pk_accsubj\":\"100203\",\n" +
//                    "                    \"pk_currtype\":\"CNY\"\n" +
//                    "                }," +
//                    "{\n" +
//                    "\t\t\t\t\"ass\":[\n" +
//                    "                        {\n" +
//                    "                            \"checktypecode\":\"73\",\n" +
//                    "                            \"checkvaluecode\":'"+ksbm+"'\n" +//客商辅助核算编码
//                    "                        },\n" +
//                    "                    ],\n" +
//                    "                    \"creditamount\":\""+je+"\",\n" +
//                    "                    \"creditquantity\":\"\",\n" +
//                    "                    \"debitamount\":\"\",\n" +
//                    "                    \"debitquantity\":\"\",\n" +
//                    "                    \"detailindex\":\"\",\n" +
//                    "                    \"excrate1\":\"\",\n" +
//                    "                    \"explanation\":\"门店货款\",\n" +
//                    "                    \"localcreditamount\":\"\",\n" +
//                    "                    \"localdebitamount\":\"\",\n" +
//                    "                    \"pk_accsubj\":\"1122\",\n" +
//                    "                    \"pk_currtype\":\"CNY\",\n" +
//                    "                    \"price\":\"\"\n" +
//                    "                },\n");
//            sb.append("            ],\n" +
//                    "            \"pk_corp\":"+bh+",\n" +
//                    "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
//                    "            \"pk_prepared\":\"15253172037\",\n" +
//                    "            \"pk_vouchertype\":\"记账\",\n" +
//                    "            \"prepareddate\":\""+zdrq+"\"\n" +
//                    "        }\n" +
//                    "    ]\n" +
//                    "}");
//
//            //System.out.println("sb:"+sb.toString());
//            HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
//            String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
//            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
//            //System.out.println("result:"+result);
//            JsonParser jp = new JsonParser();
//            //将json字符串转化成json对象
//            JsonObject jo = jp.parse(result).getAsJsonObject();
//            //获取status对应的值
//            String status = jo.get("status").getAsString();

//            if (status.equals("falied")) {
//                String errormsg = jo.get("errormsg").getAsString();
//                BtyShdkmx shdkmx=shdkmxMapper.selectOne(new QueryWrapper<BtyShdkmx>().eq("dm",dm).eq("yhk",yhk));
//                if(ToolUtil.isNotEmpty(shdkmx)){
//                    shdkmx.setErrormsg(errormsg);
//                    shdkmxMapper.updateById(shdkmx);
//                }
//                System.out.println("errormsg:"+errormsg);
//            } else {
//                BtyShdkmx shdkmx=shdkmxMapper.selectOne(new QueryWrapper<BtyShdkmx>().eq("dm",dm).eq("yhk",yhk));
//                if(ToolUtil.isNotEmpty(shdkmx)){
//                    shdkmx.setFlag(1);
//                    shdkmxMapper.updateById(shdkmx);
//                }
//            }
        //}
    }
    @Test
    public void pjkPz(){
        String bh="201";
        List<BtyPjkResult> list=pjkMapper.pjkList();
        for (BtyPjkResult mxResult : list) {
            BigDecimal je = mxResult.getJe();
            String ksbm ="";
            String dm = mxResult.getDm();
            String zdrq=mxResult.getZdrq();
            String yhk=mxResult.getYhk();
            //根据店名查询客商辅助核算编码
            String json = "{\"custname\":\""+dm+"\"}";
            RestTemplate restTemplate = new RestTemplate();
            HttpHeaders headers = new HttpHeaders();
            MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
            headers.setContentType(type);
            headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
            headers.add("system", "001"); // 系统编码
            headers.add("usercode", "15253172037"); // 用户
            headers.add("password", "514576f58a89767b46c1b44767a08f77");
            headers.add("Accept", MediaType.APPLICATION_JSON.toString());

            HttpEntity<String> formEntitys = new HttpEntity<String>(json, headers);
            String urls = "http://124.70.28.147:8088/u8cloud/api/uapbd/custdoc/query";

            Yfd yfd = restTemplate.postForEntity(urls, formEntitys, Yfd.class).getBody();
            JSONObject resultObject = JSON.parseObject(yfd.getData());
            JSONArray jsonArray = resultObject.getJSONArray("datas");
            JSONObject jsonObject;
            if (jsonArray != null) {
                for (int i = 0; i < jsonArray.size(); i++) {
                    jsonObject = jsonArray.getJSONObject(0);
                    Ksda.DatasBean.ParentvoBean parentvo = jsonObject.getObject("parentvo", Ksda.DatasBean.ParentvoBean.class);
                    ksbm=parentvo.getCustcode();
                }
            }

            StringBuilder sb=new StringBuilder();
            sb.append("{\n" +
                    "    \"voucher\":[\n" +
                    "        {\n" +
                    "            \"details\":[");

            sb.append("                {\n" +
                    "                    \"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"73\",\n" +
                    "                            \"checkvaluecode\":'"+ksbm+"'\n" +//客商辅助核算编码
                    "                        }\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\"\",\n" +
                    "                    \"debitamount\":\""+je+"\",\n" +
                    "                    \"explanation\":\"啤酒款\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"2202\",\n" +
                    "                    \"pk_currtype\":\"CNY\"\n" +
                    "                }," +
                    "{\n" +
                    "\t\t\t\t\"ass\":[\n" +
                    "                        {\n" +
                    "                            \"checktypecode\":\"96\",\n" +
                    "                            \"checkvaluecode\":"+yhk+"\n" +//银行账户辅助核算
                    "                        },\n" +
                    "                    ],\n" +
                    "                    \"creditamount\":\""+je+"\",\n" +
                    "                    \"creditquantity\":\"\",\n" +
                    "                    \"debitamount\":\"\",\n" +
                    "                    \"debitquantity\":\"\",\n" +
                    "                    \"detailindex\":\"\",\n" +
                    "                    \"excrate1\":\"\",\n" +
                    "                    \"explanation\":\"啤酒款\",\n" +
                    "                    \"localcreditamount\":\"\",\n" +
                    "                    \"localdebitamount\":\"\",\n" +
                    "                    \"pk_accsubj\":\"100203\",\n" +
                    "                    \"pk_currtype\":\"CNY\",\n" +
                    "                    \"price\":\"\"\n" +
                    "                },\n");
            sb.append("            ],\n" +
                    "            \"pk_corp\":"+bh+",\n" +
                    "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                    "            \"pk_prepared\":\"15253172037\",\n" +
                    "            \"pk_vouchertype\":\"记账\",\n" +
                    "            \"prepareddate\":\""+zdrq+"\"\n" +
                    "        }\n" +
                    "    ]\n" +
                    "}");

            System.out.println("sb:"+sb.toString());
            HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
            String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
            String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
            //System.out.println("result:"+result);
            JsonParser jp = new JsonParser();
            //将json字符串转化成json对象
            JsonObject jo = jp.parse(result).getAsJsonObject();
            //获取status对应的值
            String status = jo.get("status").getAsString();

            if (status.equals("falied")) {
                String errormsg = jo.get("errormsg").getAsString();
                BtyPjk shdkmx=pjkMapper.selectOne(new QueryWrapper<BtyPjk>().eq("dm",dm).eq("yhk",yhk));
                if(ToolUtil.isNotEmpty(shdkmx)){
                    shdkmx.setErrormsg(errormsg);
                    pjkMapper.updateById(shdkmx);
                }
                System.out.println("errormsg:"+errormsg);
            } else {
                BtyPjk shdkmx=pjkMapper.selectOne(new QueryWrapper<BtyPjk>().eq("dm",dm).eq("yhk",yhk));
                if(ToolUtil.isNotEmpty(shdkmx)){
                    shdkmx.setFlag(1);
                    pjkMapper.updateById(shdkmx);
                }
            }
        }
    }
    @Test
    public  void tcmdList(){
        logger.info("==定时更新天财门店==start");
        List<BizResult>list=bizMapper.mdList();
        for (BizResult bizResult : list) {
            Integer bh=bizResult.getRecTypeId();
            String dm=bizResult.getRecType();
            //BtyBankyeb bankyeb=btyBankyebService.getOne(new QueryWrapper<BtyBankyeb>().eq("bh",bh).eq("dm",dm));
            BtyBankyeb bankyeb=btyBankyebService.getOne(new QueryWrapper<BtyBankyeb>().eq("bh",bh));
            if(ToolUtil.isEmpty(bankyeb)){
                bankyeb=new BtyBankyeb();
                bankyeb.setBh(bh.toString());
                bankyeb.setDm(dm);
                btyBankyebService.save(bankyeb);
            }else {
                if((bankyeb.getBh().equals(bh.toString()))&&(!bankyeb.getDm().equals(dm))){
                    bankyeb.setDm(dm);
                    bankyeb.setBh(bh.toString());
                    btyBankyebService.updateById(bankyeb);
                }
            }
        }
        logger.info("==定时更新天财门店==end");
    }
    @Test
    public void dysk(){
        List<BtyDyskResult> list=btyDyskService.dmList(3);
        if(list.size()>0){
            for (BtyDyskResult dyskResult : list) {
                String yyr=dyskResult.getHxsj();
                String dm=dyskResult.getDm();
                BigDecimal dysk=dyskResult.getDzje();
                BigDecimal yye=dyskResult.getYye();
                BigDecimal sxf=dyskResult.getSxf();
                String dydm=dyskResult.getHxmd();
                Yybb yybb=yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming",dm).eq("yyr",yyr));
                if(ToolUtil.isNotEmpty(yybb)){
                    if(ToolUtil.isNotEmpty(yybb.getDy())){
                        yybb.setDy(yybb.getDy().add(dysk));
                    }else {
                        yybb.setDy(dysk);
                    }
                    if(ToolUtil.isNotEmpty(yybb.getDyyye())){
                        yybb.setDyyye(yybb.getDyyye().add(yye));
                    }else {
                        yybb.setDyyye(yye);
                    }
                    if(ToolUtil.isNotEmpty(yybb.getDysxf())){
                        yybb.setDysxf(yybb.getDysxf().add(sxf));
                    }else {
                        yybb.setDysxf(sxf);
                    }
                    yybbService.updateById(yybb);
                    BtyDyskParam param1=new BtyDyskParam();
                    param1.setHxmd(dydm);
                    btyDyskMapper.updateByMdid(param1);
                }
            }
        }
    }
    @Test
    public void xjsj(){
        try {
            logger.info("===更新现金实交金额====start");
            //根据营业日获取现金实交金额
            String time = DateUtil.getLastYearstoday(new Date());
            List<YybbResult> list = yybbService.xjsjList(time);
            if (list.size() > 0) {
                for (YybbResult yybbResult : list) {
                    Yybb yybb = yybbService.getById(yybbResult.getId());
                    yybb.setXjsj(yybbResult.getXjsj());
                    yybb.setXjsjsxf(yybbResult.getXjsjsxf());
                    yybbService.updateById(yybb);
                }
            }
            logger.info("===更新现金实交金额数"+list.size()+"====end");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    @Test
    public void hycys(){
        try {
            logger.info("====定时保存会员差异数据开始====");
            //String yesterDayDate = DateUtil.getYesterDayDate();
            String yesterDayDate = "2022-01-22";
            BtyHykParam param = new BtyHykParam();
            param.setYyr(yesterDayDate);
            List<BtyHykResult> list3 = hykService.listMdxfbj(param);
            DecimalFormat df = new DecimalFormat("#.00");
            if (list3.size() > 0) {
                for (BtyHykResult btyHykResult : list3) {
                    BigDecimal xj = BigDecimal.ZERO;
                    BigDecimal zfb = BigDecimal.ZERO;
                    BigDecimal wx = BigDecimal.ZERO;
                    BigDecimal jhsk = BigDecimal.ZERO;
                    BigDecimal dpmd = BigDecimal.ZERO;
                    //嘉联支付
                    BigDecimal jlzf = BigDecimal.ZERO;
                    //商场收款
                    BigDecimal scsk = BigDecimal.ZERO;
                    String dm = btyHykResult.getDm();
                    param.setDm(dm);
                    List<BtyHykResult> list2 = hykService.listMdByDm(param);
                    for (BtyHykResult hykResult : list2) {
                        String czlxmc = hykResult.getCzlxmc();
                        if(czlxmc.equals("现金")) {
                            xj = hykResult.getCzje();
                        }
                        else if (czlxmc.equals("支付宝")) {
                            zfb = hykResult.getCzje();
                        } else if (czlxmc.equals("微信")) {
                            wx = hykResult.getCzje();
                        } else if (czlxmc.equals("建行收款")) {
                            jhsk = hykResult.getCzje();
                        } else if (czlxmc.equals("点评买单")) {
                            dpmd = hykResult.getCzje();
                        } else if (czlxmc.equals("嘉联支付")) {
                            jlzf = hykResult.getCzje();
                        } else if (czlxmc.equals("商场收款")) {
                            scsk = hykResult.getCzje();
                        }
                        else  if (czlxmc.contains("现金:")&&czlxmc.contains("，")) {
                            String [] yj=czlxmc.split("，");
                            Pattern p=Pattern.compile("([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])");
                            for (String s : yj) {
                                Matcher m=p.matcher(s);
                                String km=m.replaceAll("").trim();
                                System.out.println("km:"+km);
                                String yjss=s.substring(km.length());
                                BigDecimal yajin=  new BigDecimal(yjss).setScale(2, BigDecimal.ROUND_HALF_UP);
                                if(km.equals("现金:")){
                                    xj=yajin;
                                }
                                System.out.println("金额:"+yajin);
                            }

                        }else if (czlxmc.contains("现金:")) {
                            xj=hykResult.getCzje();
                        }
                    }
                    //获取yybb中的现金差异
                    BigDecimal xjcy = BigDecimal.ZERO;
                    BigDecimal zfbcy = BigDecimal.ZERO;
                    BigDecimal wxcy = BigDecimal.ZERO;
                    BigDecimal mdcy = BigDecimal.ZERO;
                    BigDecimal jhcy = BigDecimal.ZERO;

                    BigDecimal hycy1 = BigDecimal.ZERO;
                    BigDecimal hycy2 = BigDecimal.ZERO;
                    BigDecimal hycy3 = BigDecimal.ZERO;
                    BigDecimal hycy4 = BigDecimal.ZERO;
                    BigDecimal hycy5 = BigDecimal.ZERO;

                    jhsk = jhsk.add(jlzf);

                    Yybb yybb = yybbService.getOne(new QueryWrapper<Yybb>().eq("dianming", dm).eq("yyr", yesterDayDate));
                    if (ToolUtil.isNotEmpty(yybb)) {
                        xjcy = yybb.getXjce();
                        zfbcy = yybb.getZfbcy();
                        wxcy = yybb.getWxcy();
                        mdcy = yybb.getMtcy();
                        jhcy = yybb.getYhkcy();
                        String xjbz = yybb.getXjbz();
                        String wxbz = yybb.getWxbz();
                        String yhkbz = yybb.getYhkbz();

                        int xjFlag = xj.compareTo(BigDecimal.ZERO);
                        int wxFlag = wx.compareTo(BigDecimal.ZERO);
                        int jhskFlag = jhsk.compareTo(BigDecimal.ZERO);
                        if (xjFlag == 1) {
                            String xjs = df.format(xj);
                            if (ToolUtil.isNotEmpty(xjbz)) {
                                xjbz = xjbz + "," + xjs;
                                yybb.setXjbz(xjbz);
                            } else {
                                yybb.setXjbz(xjs);
                            }
                            yybbService.updateById(yybb);
                        }
                        if (wxFlag == 1) {
                            String wxs = df.format(wx);
                            if (ToolUtil.isNotEmpty(wxbz)) {
                                wxbz = wxbz + "," + wxs;
                                yybb.setWxbz(wxbz);
                            } else {
                                yybb.setWxbz(wxs);
                            }
                            yybbService.updateById(yybb);
                        }
                        if (jhskFlag == 1) {
                            String jhsks = df.format(jhsk);
                            if (ToolUtil.isNotEmpty(yhkbz)) {
                                yhkbz = yhkbz + "," + jhsks;
                                yybb.setYhkbz(yhkbz);
                            } else {
                                yybb.setYhkbz(jhsks);
                            }
                            yybbService.updateById(yybb);
                        }
                    }
                    BtyHycy hycy = new BtyHycy();
                    hycy.setMc(dm);
                    hycy.setHyxj(xj);
                    hycy.setHyzfb(zfb);
                    hycy.setHywx(wx);
                    hycy.setHymd(dpmd);
                    hycy.setMdzy(mdcy);
                    hycy.setScsk(scsk);

                    hycy.setHyjh(jhsk);
                    hycy.setXjcy(xjcy);
                    hycy.setZfbcy(zfbcy);
                    hycy.setWxcy(wxcy);
                    hycy.setJhcy(jhcy);
                    hycy.setRq(yesterDayDate);
                    hycy1 = xjcy.subtract(xj);
                    hycy2 = zfbcy.subtract(zfb);
                    hycy3 = wxcy.subtract(wx);
                    hycy4 = mdcy.subtract(dpmd);
                    hycy5 = jhcy.subtract(jhsk);
                    hycy.setHycy(hycy1);
                    hycy.setHycy1(hycy2);
                    hycy.setHycy2(hycy3);
                    hycy.setHycy3(hycy4);
                    hycy.setHycy4(hycy5);
                    hycyService.save(hycy);
                }
            }
            logger.info("====定时保存会员差异数据结束====");
        } catch (Exception e) {
            String err = e.getMessage();
            String data = "定时保存会员差异数据出现异常！";
            JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, err, DateUtil.getNow(), data);
            String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
            weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
            logger.info("====定时保存会员差异数据出现异常====" + e);
            e.printStackTrace();
        }
    }

   @Test
   public  void dypz(){
       //导入成功之后按状态和大区生成凭证
       String zdrq="2022-01-25";
       //全国
       List<BtyDyResult>list=dyMapper.dyList(1);
       List<BtyDyResult>listQg=dyMapper.dyList(2);
       //江苏
       List<BtyDyResult>listJs=dyMapper.dyList(3);
       //安徽
       List<BtyDyResult>listAh=dyMapper.dyList(4);
       if(list.size()>0){
           for (BtyDyResult dy : list) {
               BigDecimal amount=dy.getAmount();
               String bh=dy.getBh();
               String yaoma=dy.getYaoma();
               String kh=dy.getKh();
               String dm=dy.getDm();
               RestTemplate restTemplate = new RestTemplate();
               HttpHeaders headers = new HttpHeaders();
               MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
               headers.setContentType(type);
               headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
               headers.add("system", "001"); // 系统编码
               headers.add("usercode", "15253172037"); // 用户
               headers.add("password", "514576f58a89767b46c1b44767a08f77");
               headers.add("Accept", MediaType.APPLICATION_JSON.toString());

               StringBuilder sb=new StringBuilder();
               sb.append("{\n" +
                       "    \"voucher\":[\n" +
                       "        {\n" +
                       "            \"details\":[");

               //全国抖音凭证
               sb.append("                {\n" +
                       "                    \"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"96\",\n" +
                       "                            \"checkvaluecode\":'"+kh+"'\n" +
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\"\",\n" +
                       "                    \"debitamount\":\""+amount+"\",\n" +
                       "                    \"explanation\":\"全国抖音\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"100202\",\n" +
                       "                    \"pk_currtype\":\"CNY\"\n" +
                       "                }," +
                       "{\n" +
                       "\t\t\t\t\"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "\t\t\t\t\t\t{\n" +
                       "                            \"checktypecode\":\"7\",\n" +
                       "                            \"checkvaluecode\":\"0323\"\n" +//全国抖音辅助核算编码
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\""+amount+"\",\n" +
                       "                    \"creditquantity\":\"\",\n" +
                       "                    \"debitamount\":\"\",\n" +
                       "                    \"debitquantity\":\"\",\n" +
                       "                    \"detailindex\":\"\",\n" +
                       "                    \"excrate1\":\"\",\n" +
                       "                    \"explanation\":\"全国抖音\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"112231\",\n" +
                       "                    \"pk_currtype\":\"CNY\",\n" +
                       "                    \"price\":\"\"\n" +
                       "                },\n");
               sb.append("            ],\n" +
                       "            \"pk_corp\":"+bh+",\n" +
                       "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                       "            \"pk_prepared\":\"15253172037\",\n" +
                       "            \"pk_vouchertype\":\"记账\",\n" +
                       "            \"prepareddate\":\""+zdrq+"\"\n" +
                       "        }\n" +
                       "    ]\n" +
                       "}");
               //System.out.println("sb:"+sb.toString());
               HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
               String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
               String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
               System.out.println("result:"+result);
               JsonParser jp = new JsonParser();
               //将json字符串转化成json对象
               JsonObject jo = jp.parse(result).getAsJsonObject();
               //获取errcode对应的值
               String status = jo.get("status").getAsString();

               if(status.equals("falied")){
                   String errormsg = jo.get("errormsg").getAsString();
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",1));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setErrormsg(errormsg);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("errormsg:"+errormsg);
               }else{
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",1));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setFlag(1);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("凭证导入成功！");
               }
           }
       }
       if(listQg.size()>0){
           for (BtyDyResult dy : listQg) {
               BigDecimal amount=dy.getAmount();
               String bh=dy.getBh();
               String yaoma=dy.getYaoma();
               String kh=dy.getKh();
               String dm=dy.getDm();
               RestTemplate restTemplate = new RestTemplate();
               HttpHeaders headers = new HttpHeaders();
               MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
               headers.setContentType(type);
               headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
               headers.add("system", "001"); // 系统编码
               headers.add("usercode", "15253172037"); // 用户
               headers.add("password", "514576f58a89767b46c1b44767a08f77");
               headers.add("Accept", MediaType.APPLICATION_JSON.toString());

               StringBuilder sb=new StringBuilder();
               sb.append("{\n" +
                       "    \"voucher\":[\n" +
                       "        {\n" +
                       "            \"details\":[");

               //全国抖音凭证
               sb.append("                {\n" +
                       "                    \"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"96\",\n" +
                       "                            \"checkvaluecode\":'"+kh+"'\n" +
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\"\",\n" +
                       "                    \"debitamount\":\""+amount+"\",\n" +
                       "                    \"explanation\":\"全国抖音\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"100202\",\n" +
                       "                    \"pk_currtype\":\"CNY\"\n" +
                       "                }," +
                       "{\n" +
                       "\t\t\t\t\"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "\t\t\t\t\t\t{\n" +
                       "                            \"checktypecode\":\"7\",\n" +
                       "                            \"checkvaluecode\":\"0323\"\n" +//全国抖音辅助核算编码
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\""+amount+"\",\n" +
                       "                    \"creditquantity\":\"\",\n" +
                       "                    \"debitamount\":\"\",\n" +
                       "                    \"debitquantity\":\"\",\n" +
                       "                    \"detailindex\":\"\",\n" +
                       "                    \"excrate1\":\"\",\n" +
                       "                    \"explanation\":\"全国抖音\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"112231\",\n" +
                       "                    \"pk_currtype\":\"CNY\",\n" +
                       "                    \"price\":\"\"\n" +
                       "                },\n");
               sb.append("            ],\n" +
                       "            \"pk_corp\":"+bh+",\n" +
                       "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                       "            \"pk_prepared\":\"15253172037\",\n" +
                       "            \"pk_vouchertype\":\"记账\",\n" +
                       "            \"prepareddate\":\""+zdrq+"\"\n" +
                       "        }\n" +
                       "    ]\n" +
                       "}");
               //System.out.println("sb:"+sb.toString());
               HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
               String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
               String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
               System.out.println("result:"+result);
               JsonParser jp = new JsonParser();
               //将json字符串转化成json对象
               JsonObject jo = jp.parse(result).getAsJsonObject();
               //获取errcode对应的值
               String status = jo.get("status").getAsString();
               if(status.equals("falied")){
                   String errormsg = jo.get("errormsg").getAsString();
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",2));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setErrormsg(errormsg);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("errormsg:"+errormsg);
               }else{
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",2));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setFlag(1);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("凭证导入成功！");
               }
           }
       }
       if(listJs.size()>0){
           for (BtyDyResult dy : listJs) {
               BigDecimal amount=dy.getAmount();
               String bh=dy.getBh();
               String yaoma=dy.getYaoma();
               String kh=dy.getKh();
               String dm=dy.getDm();
               RestTemplate restTemplate = new RestTemplate();
               HttpHeaders headers = new HttpHeaders();
               MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
               headers.setContentType(type);
               headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
               headers.add("system", "001"); // 系统编码
               headers.add("usercode", "15253172037"); // 用户
               headers.add("password", "514576f58a89767b46c1b44767a08f77");
               headers.add("Accept", MediaType.APPLICATION_JSON.toString());

               StringBuilder sb=new StringBuilder();
               sb.append("{\n" +
                       "    \"voucher\":[\n" +
                       "        {\n" +
                       "            \"details\":[");

               //江苏凭证
               sb.append("                {\n" +
                       "                    \"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"96\",\n" +
                       "                            \"checkvaluecode\":'"+kh+"'\n" +
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\"\",\n" +
                       "                    \"debitamount\":\""+amount+"\",\n" +
                       "                    \"explanation\":\"抖音收款\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"100202\",\n" +
                       "                    \"pk_currtype\":\"CNY\"\n" +
                       "                }," +
                       "{\n" +
                       "\t\t\t\t\"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "\t\t\t\t\t\t{\n" +
                       "                            \"checktypecode\":\"7\",\n" +
                       "                            \"checkvaluecode\":\"0017\"\n" +//抖音收款辅助核算编码
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\""+amount+"\",\n" +
                       "                    \"creditquantity\":\"\",\n" +
                       "                    \"debitamount\":\"\",\n" +
                       "                    \"debitquantity\":\"\",\n" +
                       "                    \"detailindex\":\"\",\n" +
                       "                    \"excrate1\":\"\",\n" +
                       "                    \"explanation\":\"抖音收款\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"112220\",\n" +
                       "                    \"pk_currtype\":\"CNY\",\n" +
                       "                    \"price\":\"\"\n" +
                       "                },\n");
               sb.append("            ],\n" +
                       "            \"pk_corp\":"+bh+",\n" +
                       "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                       "            \"pk_prepared\":\"15253172037\",\n" +
                       "            \"pk_vouchertype\":\"记账\",\n" +
                       "            \"prepareddate\":\""+zdrq+"\"\n" +
                       "        }\n" +
                       "    ]\n" +
                       "}");
               //System.out.println("sb:"+sb.toString());
               HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
               String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
               String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
               System.out.println("result:"+result);
               JsonParser jp = new JsonParser();
               //将json字符串转化成json对象
               JsonObject jo = jp.parse(result).getAsJsonObject();
               //获取errcode对应的值
               String status = jo.get("status").getAsString();
               if(status.equals("falied")){
                   String errormsg = jo.get("errormsg").getAsString();
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",3));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setErrormsg(errormsg);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("errormsg:"+errormsg);
               }else{
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",3));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setFlag(1);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("凭证导入成功！");
               }

           }
       }
       if(listAh.size()>0){
           for (BtyDyResult dy : listAh) {
               BigDecimal amount=dy.getAmount();
               String bh=dy.getBh();
               String yaoma=dy.getYaoma();
               String kh=dy.getKh();
               String dm=dy.getDm();
               RestTemplate restTemplate = new RestTemplate();
               HttpHeaders headers = new HttpHeaders();
               MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
               headers.setContentType(type);
               headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
               headers.add("system", "001"); // 系统编码
               headers.add("usercode", "15253172037"); // 用户
               headers.add("password", "514576f58a89767b46c1b44767a08f77");
               headers.add("Accept", MediaType.APPLICATION_JSON.toString());

               StringBuilder sb=new StringBuilder();
               sb.append("{\n" +
                       "    \"voucher\":[\n" +
                       "        {\n" +
                       "            \"details\":[");

               //安徽直播凭证
               sb.append("                {\n" +
                       "                    \"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"96\",\n" +
                       "                            \"checkvaluecode\":'"+kh+"'\n" +
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\"\",\n" +
                       "                    \"debitamount\":\""+amount+"\",\n" +
                       "                    \"explanation\":\"安徽直播\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"100202\",\n" +
                       "                    \"pk_currtype\":\"CNY\"\n" +
                       "                }," +
                       "{\n" +
                       "\t\t\t\t\"ass\":[\n" +
                       "                        {\n" +
                       "                            \"checktypecode\":\"2\",\n" +
                       "                            \"checkvaluecode\":'"+yaoma+"'\n" +
                       "                        },\n" +
                       "\t\t\t\t\t\t{\n" +
                       "                            \"checktypecode\":\"7\",\n" +
                       "                            \"checkvaluecode\":\"0319\"\n" +//直播收款辅助核算编码
                       "                        }\n" +
                       "                    ],\n" +
                       "                    \"creditamount\":\""+amount+"\",\n" +
                       "                    \"creditquantity\":\"\",\n" +
                       "                    \"debitamount\":\"\",\n" +
                       "                    \"debitquantity\":\"\",\n" +
                       "                    \"detailindex\":\"\",\n" +
                       "                    \"excrate1\":\"\",\n" +
                       "                    \"explanation\":\"安徽直播\",\n" +
                       "                    \"localcreditamount\":\"\",\n" +
                       "                    \"localdebitamount\":\"\",\n" +
                       "                    \"pk_accsubj\":\"112220\",\n" +
                       "                    \"pk_currtype\":\"CNY\",\n" +
                       "                    \"price\":\"\"\n" +
                       "                },\n");
               sb.append("            ],\n" +
                       "            \"pk_corp\":"+bh+",\n" +
                       "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
                       "            \"pk_prepared\":\"15253172037\",\n" +
                       "            \"pk_vouchertype\":\"记账\",\n" +
                       "            \"prepareddate\":\""+zdrq+"\"\n" +
                       "        }\n" +
                       "    ]\n" +
                       "}");
               //System.out.println("sb:"+sb.toString());
               HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
               String url = "http://124.70.28.147:8088/u8cloud/api/gl/voucher/insert";
               String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
               System.out.println("result:"+result);
               JsonParser jp = new JsonParser();
               //将json字符串转化成json对象
               JsonObject jo = jp.parse(result).getAsJsonObject();
               //获取errcode对应的值
               String status = jo.get("status").getAsString();
               if(status.equals("falied")){
                   String errormsg = jo.get("errormsg").getAsString();
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",4));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setErrormsg(errormsg);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("errormsg:"+errormsg);
               }else{
                   BtyDy dy1=dyMapper.selectOne(new QueryWrapper<BtyDy>().eq("dm",dm).eq("state",4));
                   if(ToolUtil.isNotEmpty(dy1)){
                       dy1.setFlag(1);
                       dyMapper.updateById(dy1);
                   }
                   //System.out.println("凭证导入成功！");
               }

           }
       }
   }

   @Test
   public  void dysxfpz(){
        String zdrq="2022-01-26";
       //生成全国抖音凭证
       BtyDysxfParam param3=new BtyDysxfParam();
       param3.setState(2);
       param3.setFlag(0);
//       List<BtyDysxfResult>qgList=dysxfMapper.dysxfList(param3);
//       for (BtyDysxfResult btyDysxf : qgList) {
//           BigDecimal sxf=btyDysxf.getSxf();
//           String bh=btyDysxf.getRegion();
//           String yaoma=btyDysxf.getYaoma();
//           String dm=btyDysxf.getDm();
//           RestTemplate restTemplate = new RestTemplate();
//           HttpHeaders headers = new HttpHeaders();
//           MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
//           headers.setContentType(type);
//           headers.add("trantype", "code"); // 档案翻译方式，枚举值为：编码请录入 code， 名称请录入 name， 主键请录入 pk
//           headers.add("system", "001"); // 系统编码
//           headers.add("usercode", "15253172037"); // 用户
//           headers.add("password", "514576f58a89767b46c1b44767a08f77");
//           headers.add("Accept", MediaType.APPLICATION_JSON.toString());
//
//           StringBuilder sb=new StringBuilder();
//           sb.append("{\n" +
//                   "    \"voucher\":[\n" +
//                   "        {\n" +
//                   "            \"details\":[");
//
//           //抖音手续费凭证
//           sb.append("                {\n" +
//                   "                    \"ass\":[\n" +
//                   "                        {\n" +
//                   "                            \"checktypecode\":\"2\",\n" +
//                   "                            \"checkvaluecode\":'"+yaoma+"'\n" +
//                   "                        }\n" +
//                   "                    ],\n" +
//                   "                    \"creditamount\":\"\",\n" +
//                   "                    \"debitamount\":\""+sxf+"\",\n" +
//                   "                    \"explanation\":\"全国抖音直播手续费\",\n" +
//                   "                    \"localcreditamount\":\"\",\n" +
//                   "                    \"localdebitamount\":\"\",\n" +
//                   "                    \"pk_accsubj\":\"660306\",\n" +
//                   "                    \"pk_currtype\":\"CNY\"\n" +
//                   "                }," +
//                   "{\n" +
//                   "\t\t\t\t\"ass\":[\n" +
//                   "                        {\n" +
//                   "                            \"checktypecode\":\"2\",\n" +
//                   "                            \"checkvaluecode\":'"+yaoma+"'\n" +
//                   "                        },\n" +
//                   "\t\t\t\t\t\t{\n" +
//                   "                            \"checktypecode\":\"7\",\n" +
//                   "                            \"checkvaluecode\":\"0323\"\n" +//全国抖音收款辅助核算编码
//                   "                        }\n" +
//                   "                    ],\n" +
//                   "                    \"creditamount\":\""+sxf+"\",\n" +
//                   "                    \"creditquantity\":\"\",\n" +
//                   "                    \"debitamount\":\"\",\n" +
//                   "                    \"debitquantity\":\"\",\n" +
//                   "                    \"detailindex\":\"\",\n" +
//                   "                    \"excrate1\":\"\",\n" +
//                   "                    \"explanation\":\"全国抖音直播手续费\",\n" +
//                   "                    \"localcreditamount\":\"\",\n" +
//                   "                    \"localdebitamount\":\"\",\n" +
//                   "                    \"pk_accsubj\":\"112231\",\n" +
//                   "                    \"pk_currtype\":\"CNY\",\n" +
//                   "                    \"price\":\"\"\n" +
//                   "                },\n");
//           sb.append("            ],\n" +
//                   "            \"pk_corp\":"+bh+",\n" +
//                   "            \"pk_glorgbook\":\""+bh+"-bty01\",\n" +
//                   "            \"pk_prepared\":\"15253172037\",\n" +
//                   "            \"pk_vouchertype\":\"记账\",\n" +
//                   "            \"prepareddate\":\""+zdrq+"\"\n" +
//                   "        }\n" +
//                   "    ]\n" +
//                   "}");
//           //System.out.println("sb:"+sb.toString());
//           HttpEntity<String> formEntity = new HttpEntity<String>(sb.toString(), headers);
//           String url = "http://124.70.28.147:8089/u8cloud/api/gl/voucher/insert";
//           String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
//           //System.out.println("result:"+result);
//           JsonParser jp = new JsonParser();
//           //将json字符串转化成json对象
//           JsonObject jo = jp.parse(result).getAsJsonObject();
//           //获取status对应的值
//           String status = jo.get("status").getAsString();
//
//           if(status.equals("falied")){
//               String errormsg = jo.get("errormsg").getAsString();
//               BtyDysxf dysxf=dysxfMapper.selectOne(new QueryWrapper<BtyDysxf>().eq("state",2).eq("dm",dm));
//               if(ToolUtil.isNotEmpty(dysxf)){
//                   dysxf.setErrormsg(errormsg);
//                   dysxfMapper.updateById(dysxf);
//               }
////
//           }else{
//               BtyDysxf dysxf=dysxfMapper.selectOne(new QueryWrapper<BtyDysxf>().eq("state",2).eq("dm",dm));
//               if(ToolUtil.isNotEmpty(dysxf)){
//                   dysxf.setFlag(1);
//                   dysxfMapper.updateById(dysxf);
//               }
//               System.out.println("凭证生成成功！");
//           }
//       }
   }
    @Test
    public void salesDataZz() {
            BigDecimal netAmount = BigDecimal.ZERO;
            try {
                logger.info("===更新郑州二七万象城店数据开始...");
                String yesterday = DateUtil.getYesterDay4Oclock();
                String today = DateUtil.getToday4Oclock();
                String nextday = DateUtil.getNextDay4Oclock();
                Timestamp yesterdayTime = Timestamp.valueOf(yesterday);
                Timestamp todayTime = Timestamp.valueOf(today);
                Timestamp nextdayTime = Timestamp.valueOf(nextday);
                //获取郑州二七万象城店销售额
                //String money = bizService.lastMoneyByShopCode("1091", todayTime, nextdayTime);
                String money = "0";
                if (ToolUtil.isNotEmpty(money)) {
                    netAmount = new BigDecimal(money);
                }
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:SSS");
                String now = sdf.format(new Date());
                String nowDate = DateUtil.getStampNow();
                logger.info("郑州二七万象城店销售额：" + money);
                String str[] = {};
                Map map = new HashMap();
                map.put("cardBank", "");
                map.put("cardNumber", "");
                map.put("discountAmt", 0);
                map.put("payAmt", money);
                map.put("paymentMethod", "CH");
                map.put("time", nowDate);
                map.put("value", money);
                List<Map<String, Object>> payList = new ArrayList<>();
                payList.add(map);

                RestTemplate restTemplate = new RestTemplate();
                JSONObject dataJson = new JSONObject();
                //收银员编号
                dataJson.put("cashierId", "2601a001all606a0101");
                //店铺验证密钥
                dataJson.put("checkCode", "ALL606A01@Crland");
                //备注
                dataJson.put("comments", "comments");
                dataJson.put("itemList", str);
                //商场编号
                dataJson.put("mall", "2601A001");
                dataJson.put("mobile", "");
                //订单号
                dataJson.put("orderId", nowDate);
                dataJson.put("payList", payList);
                dataJson.put("refOrderId", "refOrderId");
                //店铺编号
                //dataJson.put("store", "ALL606A01");
                dataJson.put("store", "ALL606A01");
                //收银机编号
                dataJson.put("tillId", "01");
                dataJson.put("time", nowDate);
                //订单总金额
                dataJson.put("totalAmt", money);
                dataJson.put("type", "SALE");
                //dataJson.put("type", "ONLINEREFUND");
                //来源 01 店铺 02数据采集盒子
                dataJson.put("source", "01");
                //合作伙伴身份标识
                String Partner_ID = "70000029";
                //调用的API版本号
                String Api_Version = "1.0.1";
                //被调用API的应用编码
                String App_Sub_ID = "10000187223BQ";
                //API调用的API编码
                String Api_ID = "mixc.imPOSWBJB.GLWXCJB.orderCollect";
                //API调用方授权令牌
                String App_Token = "0f6cfd4564d94c468ad3d6529b3eb2e1";
                //被调用API的应用编码
                String App_Pub_ID = "10000187223RL";
                //合作伙伴系统编码
                String Sys_ID = "100001872";

                //拼接待签名字符串
                String strs = "Api_ID=" + Api_ID + "&Api_Version=" + Api_Version + "&App_Pub_ID=" + App_Pub_ID + "&App_Sub_ID=" + App_Sub_ID + "&App_Token=" + App_Token + "&Format=json&Partner_ID=" + Partner_ID + "&REQUEST_DATA=" +
                        dataJson.toString() + "&Sign_Method=md5&Sys_ID=" + Sys_ID + "&Time_Stamp=" + now + "&85c8b165df9046d8afb84e8998993ddd";
                //生成签名获取sign的值
                String sign = Md5Util.md5(strs);

                JSONObject contentJson = new JSONObject();
                contentJson.put("Partner_ID", Partner_ID);
                contentJson.put("Api_Version", Api_Version);
                contentJson.put("App_Sub_ID", App_Sub_ID);
                //响应格式,默认为json格式，可选值：xml或json
                contentJson.put("Format", "json");
                //时间戳，格式为yyyy-mm-ddHH:mm:ss:SSS，时区为GMT+8;10分钟以内的时间
                contentJson.put("Time_Stamp", now);
                contentJson.put("Api_ID", Api_ID);
                contentJson.put("App_Token", App_Token);
                contentJson.put("App_Pub_ID", App_Pub_ID);
                //生成服务请求签名字符串所使用的算法类型，目前仅支持MD5
                contentJson.put("Sign_Method", "md5");
                //服务请求的签名字符串
                contentJson.put("Sign", sign);
                contentJson.put("Sys_ID", Sys_ID);
                JSONObject jsons = new JSONObject();
                jsons.put("REQUEST_DATA", dataJson);
                jsons.put("HRT_ATTRS", contentJson);

                JSONObject json = new JSONObject();
                json.put("REQUEST", jsons);
                HttpHeaders headers = new HttpHeaders();
                MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
                headers.setContentType(type);
                headers.add("Accept", MediaType.APPLICATION_JSON.toString());
                //System.out.println("json:"+json.toString());
                HttpEntity<String> formEntity = new HttpEntity<String>(json.toString(), headers);
                String url = "http://ztopenapi.crland.com.cn/api-gateway/rs-service/";
                //String url = "http://ztopenapiuat.crland.com.cn:81/api-gateway/rs-service/";
                String result = restTemplate.postForEntity(url, formEntity, String.class).getBody();
                //System.out.println("result:"+result);
                JsonParser jp = new JsonParser();
                //将json字符串转化成json对象
                JsonObject jo = jp.parse(result).getAsJsonObject();
                //获取errcode对应的值
                String errcode = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errcode").getAsString();
                String errmsg = jo.get("RETURN_DATA").getAsJsonObject().get("header").getAsJsonObject().get("errmsg").getAsString();
                if (errcode.equals("0000")) {
                    logger.info("===郑州二七万象城店销售数据更新成功！");
                } else {
                    String data = "更新郑州二七万象城店销售额" + netAmount + "数据出现异常！result=" + result;
                    JSONObject tempObj = weChatSendTempMsgService.setTempParam(data, data, data, result, DateUtil.getNow(), data);
                    String[] openids = new String[]{"oM18PwW_aRtOaOH0F-YwsmMxT2sM"};
                    weChatSendTempMsgService.sendmsg(openids, BusConst.MSURL, tempObj);
                    logger.info("郑州二七万象城店错误码：" + errcode + "错误信息:" + errmsg);
                }
            } catch (Exception e) {
                logger.error("更新郑州二七万象城店销售数据 出现异常", e);
                e.printStackTrace();
            }
    }
    int firstflag = 1;
    @Test
    public void stopProject() throws ParseException {
        logger.info("stopProject start...");
        ProjectParam param = new ProjectParam();
        String end = DateUtil.addDate(DateUtil.getNowDate(), -3);
        param.setEndTime(end);

        //首次处理时，不限定开始时间，为了提高效率以后处理7天前-3天前的数据
        String start = DateUtil.addDate(DateUtil.getNowDate(), -7);
        if (firstflag > 1) {
            param.setBeginTime(start);
        }
        logger.debug("stopProject param={}", param);
        List<TaskStatus> list = projectService.listgcsToStop(param);
        if (list.size() > 0) {
            for (TaskStatus tt : list) {
                logger.debug("stopProject 工程id={}", tt.getProId());
                Project pp = new Project();
                pp.setStatus(BusConst.NOPASS);
                pp.setId(tt.getProId());
                projectMapper.updateById(pp);
            }
        }
        firstflag++;
        logger.info("stopProject end.");
    }
//     @Test
//    public void test111s(){
//         BigDecimal pkje=BigDecimal.ZERO;
//         BigDecimal tprkje=BigDecimal.ZERO;
//         List<BtyWmhResult>sflbList=btyWmhService.sflbList("");
//         for (BtyWmhResult wmhResult : sflbList) {
//             if(wmhResult.getSflb().equals("盘亏出库")){
//                 pkje=wmhResult.getCkje();
//             }
//             if(wmhResult.getSflb().equals("门店统配入库")){
//                 tprkje=wmhResult.getRkje();
//             }
//         }
//         System.out.println("盘亏金额："+pkje);
//         System.out.println("统配入库金额："+tprkje);
//    }

    @Autowired
    private EmpService empService;

    @Autowired
    private DingdingDayAttendService dingdingDayAttendService;

    @Resource
    private DingdingUtil dingdingUtil;

    @Resource
    private DingdingDayRequestService dingdingDayRequestService;

    @Test
    public void testAttend() {
        // 备注(bz)获取需要考勤的员工
        QueryWrapper qw = new QueryWrapper();
        qw.eq("bz", 20211125);
        List<Emp> empList = empService.list(qw);
        System.out.println("员工数: " + empList.size());
        // 批量插入list
        List<DingdingDayAttend> attendBatchData = new ArrayList<>();
        int i = 1;
        int empListLength = empList.size();
        if (empListLength > 0) {
            for (Emp emp : empList) {
                // 获取打卡记录
                List<OapiAttendanceListResponse.Recordresult> recordList = dingdingUtil.getRecordByUserId(emp.getBh());
                if (recordList.size() > 0) {
                    DingdingDayAttend dingdingDayAttend = new DingdingDayAttend();
                    dingdingDayAttend.setId(UUIDUtils.getId());
                    dingdingDayAttend.setEmpId(emp.getBh());
                    dingdingDayAttend.setAttendDay(DingdingUtil.strToDate(DingdingUtil.getYestoday()));
                    dingdingDayAttend.setCreateTime(new Date());
                    for (OapiAttendanceListResponse.Recordresult dk : recordList) {
                        String ampm = DingdingUtil.timestamp2A(dk.getUserCheckTime().getTime());
                        String time = DingdingUtil.timestamp2Time(dk.getUserCheckTime().getTime());
                        if ("上午".equals(ampm) && "OnDuty".equals(dk.getCheckType())) {
                            dingdingDayAttend.setTimeOne(time);
                        }
                        if ("上午".equals(ampm) && "OffDuty".equals(dk.getCheckType())) {
                            dingdingDayAttend.setTimeTwo(time);
                        }
                        if ("下午".equals(ampm) && "OnDuty".equals(dk.getCheckType())) {
                            dingdingDayAttend.setTimeThree(time);
                        }
                        if ("下午".equals(ampm) && "OffDuty".equals(dk.getCheckType())) {
                            dingdingDayAttend.setTimeFour(time);
                        }
                    }
                    attendBatchData.add(dingdingDayAttend);
                    if (attendBatchData.size() == 100 || i == empListLength) {
                        dingdingDayAttendService.batchInsert(attendBatchData);
                        attendBatchData.clear();
                    }
                }
                i++;
                try {
                    Thread.sleep(100);
                } catch (Exception e) {}
            }
        }
    }
    @Test
    public void test101() {
        // 备注(bz)获取需要考勤的员工
        QueryWrapper qw = new QueryWrapper();
        qw.eq("bz", 20220310);
        List<Emp> empList = empService.list(qw);
        System.out.println("员工数: " + empList.size());

        String yestoday = DingdingUtil.getYestoday();
        // 日期范围
        String from = yestoday + " 00:00:00";
        String to = yestoday + " 00:00:00";

        // attend表批量插入list
        List<DingdingDayAttend> attendBatchData = new ArrayList<>();
        List<DingdingDayRequest> requestBatchData = new ArrayList<>();
        Pattern pattern = Pattern.compile("[0-9]{2}[-][0-9]{2}");
        int i = 0;
        int empListLength = empList.size();
        if (empListLength > 0) {
            for (Emp emp : empList) {
                i++;
                OapiAttendanceGetcolumnvalResponse.ColumnValListForTopVo result = dingdingUtil.getColumnval(emp.getBh(), from, to);
                if (ObjectUtil.isNotEmpty(result)) {
                    DingdingDayAttend dingdingDayAttend = new DingdingDayAttend();
                    dingdingDayAttend.setId(UUIDUtils.getId());
                    dingdingDayAttend.setEmpId(emp.getBh());
                    dingdingDayAttend.setAttendDay(DingdingUtil.strToDate(yestoday));
                    dingdingDayAttend.setCreateTime(new Date());
                    for (OapiAttendanceGetcolumnvalResponse.ColumnValForTopVo col : result.getColumnVals()) {
                        Long id = col.getColumnVo().getId();
                        String value = col.getColumnVals().get(0).getValue();
                        // 六次打卡时间
                        if (7100724 == id) {
                            dingdingDayAttend.setTimeOne(value);
                        }
                        if (7100726 == id) {
                            dingdingDayAttend.setTimeTwo(value);
                        }
                        if (7100728 == id) {
                            dingdingDayAttend.setTimeThree(value);
                        }
                        if (7100730 == id) {
                            dingdingDayAttend.setTimeFour(value);
                        }
                        if (7100732 == id) {
                            dingdingDayAttend.setTimeFive(value);
                        }
                        if (7100734 == id) {
                            dingdingDayAttend.setTimeSix(value);
                        }

                        // 申请单
                        if (7100736 == id && ObjectUtil.isNotEmpty(value)) {
                            // 插入申请单请假单
                            DingdingDayRequest dingdingDayRequest = new DingdingDayRequest();
                            dingdingDayRequest.setId(UUIDUtils.getId());
                            dingdingDayRequest.setEmpId(emp.getBh());
                            dingdingDayRequest.setRequestDay(DingdingUtil.strToDate(yestoday));
                            dingdingDayRequest.setRequestDetail(value);
                            dingdingDayRequest.setCreateTime(new Date());

                            Matcher matcher = pattern.matcher(value);
                            List<String> matchList = new ArrayList<>();
                            while (matcher.find()) {
                                matchList.add(matcher.group(0));
                            }
                            if (matchList.size() > 0) {
                                String year = DingdingUtil.getYear();
                                dingdingDayRequest.setStartDay(DingdingUtil.strToDate(year + "-" + matchList.get(0)));
                                dingdingDayRequest.setEndDay(DingdingUtil.strToDate(year + "-" + matchList.get(matchList.size() - 1)));
                            }
                            requestBatchData.add(dingdingDayRequest);
                        }
                    }
                    // 六次打卡有一次不为空
                    if (ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeOne()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeTwo()) ||
                            ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeThree()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeFour()) ||
                            ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeFive()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeSix()))
                    {
                        attendBatchData.add(dingdingDayAttend);
                    }

                    // 集合满200条或者最后一条插入
                    if (attendBatchData.size() == 100 || i == empListLength) {
                        dingdingDayAttendService.batchInsert(attendBatchData);
                        attendBatchData.clear();
                    }

                    // 集合满200条或者最后一条插入
                    if (requestBatchData.size() == 100 || i == empListLength) {
                        dingdingDayRequestService.batchInsert(requestBatchData);
                        requestBatchData.clear();
                    }

                }
                // 暂停100毫秒
                try {Thread.sleep(100);} catch (Exception e) {}
            }
        }



    }

    @Test
    public void testdingding101() {
        // 需要考勤的员工
        QueryWrapper qw = new QueryWrapper();
//        qw.eq("status_view", "正式员工");
        List<Emp> empList = empService.list(qw);
        System.out.println("员工数: " + empList.size());

        // 日期范围
        String from ="2022-02-19 00:00:00";
        String to ="2022-03-20 00:00:00";

        // attend表批量插入list
        List<DingdingDayAttend> attendBatchData = new ArrayList<>();
        List<DingdingDayRequest> requestBatchData = new ArrayList<>();
        Pattern pattern = Pattern.compile("[0-9]{2}[-][0-9]{2}");
        int i = 0;
        int empListLength = empList.size();
        if (empListLength > 0) {
            for (Emp emp : empList) {
                i++;
                OapiAttendanceGetcolumnvalResponse.ColumnValListForTopVo result = dingdingUtil.getColumnval(emp.getBh(), from, to);
                if (ObjectUtil.isNotEmpty(result)) {
                    for (int k = 0; k < 30; k++) {
                        DingdingDayAttend dingdingDayAttend = new DingdingDayAttend();
                        dingdingDayAttend.setId(UUIDUtils.getId());
                        dingdingDayAttend.setEmpId(emp.getBh());
                        dingdingDayAttend.setCreateTime(new Date());
                        for (int j = 0; j < 7; j++) {
                            Long id = result.getColumnVals().get(j).getColumnVo().getId();
                            Date date = result.getColumnVals().get(j).getColumnVals().get(k).getDate();
                            String value = result.getColumnVals().get(j).getColumnVals().get(k).getValue();
                            // 六次打卡时间
                            if (7100724 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeOne(value);
                            }
                            if (7100726 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeTwo(value);
                            }
                            if (7100728 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeThree(value);
                            }
                            if (7100730 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeFour(value);
                            }
                            if (7100732 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeFive(value);
                            }
                            if (7100734 == id && !value.isEmpty()) {
                                dingdingDayAttend.setTimeSix(value);
                            }
                            dingdingDayAttend.setAttendDay(date);

                            // 申请单
                            if (7100736 == id && !value.isEmpty()) {
                                // 插入申请单请假单
                                DingdingDayRequest dingdingDayRequest = new DingdingDayRequest();
                                dingdingDayRequest.setId(UUIDUtils.getId());
                                dingdingDayRequest.setEmpId(emp.getBh());
                                dingdingDayRequest.setRequestDay(date);
                                dingdingDayRequest.setRequestDetail(value);
                                dingdingDayRequest.setCreateTime(new Date());

                                Matcher matcher = pattern.matcher(value);
                                List<String> matchList = new ArrayList<>();
                                while (matcher.find()) {
                                    matchList.add(matcher.group(0));
                                }
                                if (matchList.size() > 0) {
                                    String year = DingdingUtil.getYear();
                                    dingdingDayRequest.setStartDay(DingdingUtil.strToDate(year + "-" + matchList.get(0)));
                                    dingdingDayRequest.setEndDay(DingdingUtil.strToDate(year + "-" + matchList.get(matchList.size() - 1)));
                                }
                                requestBatchData.add(dingdingDayRequest);
                            }
                        }

                        // 六次打卡有一次不为空
                        if (ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeOne()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeTwo()) ||
                                ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeThree()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeFour()) ||
                                ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeFive()) || ObjectUtil.isNotEmpty(dingdingDayAttend.getTimeSix()))
                        {
                            attendBatchData.add(dingdingDayAttend);
                        }

                    }

                    // 集合满200条或者最后一条插入
                    if (attendBatchData.size() > 100 || i == empListLength) {
                        dingdingDayAttendService.batchInsert(attendBatchData);
                        attendBatchData.clear();
                    }

                    // 集合满200条或者最后一条插入
                    if (requestBatchData.size() > 100 || i == empListLength) {
                        dingdingDayRequestService.batchInsert(requestBatchData);
                        requestBatchData.clear();
                    }

                }
                // 暂停100毫秒
                try {Thread.sleep(100);} catch (Exception e) {}
            }
        }



    }

    @Resource
    private DingdingDayAttendMapper dingdingDayAttendMapper;
    @Test
    public void testdingding102() {
        // 删除30天前数据
        QueryWrapper delQw = new QueryWrapper();
        delQw.lt("attend_day", DateUtils.addDays(new Date(), -30));
        dingdingDayAttendMapper.delete(delQw);
//        List<String> list = new ArrayList<>();
//        list.add("2147422702946194");
//        list.add("53205868843700");
//        HashMap<String, Object> s = dingdingUtil.deleteEmps(list);
//        System.out.println(s);
    }

    @Test
    public void addDouble(){
        List<BtyDoubleCardResult> list=doubleCardMapper.projectDoubleCardList(null);
            if (ToolUtil.isNotEmpty(list) && list.size() > 0) {
                for (BtyDoubleCardResult result : list) {
                    BtyDoubleCard card = new BtyDoubleCard();
                    card.setId(UUIDUtils.getId());
                    card.setGcdm(result.getGcdm());
                    card.setYaoma(result.getYaoma());
                    card.setYyjlTel(result.getYyjlTel());
                    int proId=result.getProId();
                    //根据proId查询工程指定督导的时间
//                   List<TaskFlow>flowList=taskFlowService.list(new QueryWrapper<TaskFlow>().eq("task_id",41).eq("pro_id",proId).orderByDesc("create_time"));
//                   if(flowList.size()>0){
//                    card.setCreateTime(flowList.get(0).getCreateTime());
//                   }
                    //根据营运经理电话获取姓名
                    if(ToolUtil.isEmpty(result.getYyjl())){
                        Emp emp=empService.getOne(new QueryWrapper<Emp>().eq("tel",result.getYyjlTel()));
                        if(ToolUtil.isNotEmpty(emp)){
                            card.setYyjl(emp.getXm());
                        }
                    }else{
                        card.setYyjl(result.getYyjl());
                    }

                    //根据督导电话获取姓名
                    if(ToolUtil.isEmpty(result.getDd())){
                        Emp emp=empService.getOne(new QueryWrapper<Emp>().eq("tel",result.getDdTel()));
                        if(ToolUtil.isNotEmpty(emp)){
                            card.setDd(emp.getXm());
                        }
                    }else{
                        card.setDd(result.getDd());
                    }

                    card.setDdTel(result.getDdTel());

                    //根据工程id获取流程相关信息
                    List<BtyDoubleCardResult> taskList = doubleCardMapper.taskList(result.getProId());
                    if (ToolUtil.isNotEmpty(taskList) && taskList.size() > 0) {
                        for (BtyDoubleCardResult taskResult : taskList) {
                            int taskId = taskResult.getTaskId();
                            //营业执照图片
                            if (taskId == 11) {
                                card.setBusinessLicensePic(taskResult.getContent());
                            }
                            //营业执照名称
                            if (taskId == 56) {
                                card.setBusinessLicense(taskResult.getContent());
                            }
                            //统一社会信用代码
                            if (taskId == 57) {
                                card.setSocialCreditCode(taskResult.getContent());
                            }
                            //营业执照地址
                            if (taskId == 55) {
                                card.setBusinessLicenseAddress(taskResult.getContent());
                            }
                            //法人姓名
                            if (taskId == 47) {
                                card.setFrxm(taskResult.getContent());
                            }
                            //法人身份证
                            if (taskId == 42) {
                                card.setFrsfz(taskResult.getContent());
                            }
                            //卫生许可证
                            if (taskId == 13) {
                                card.setFoodBusinessLicensePic(taskResult.getContent());
                            }
                            //卫生许可证年审日期
                            if (taskId == 44) {
                                card.setFoodBusinessLicenseDate(taskResult.getContent());
                            }
                        }
                    }
                    if (ToolUtil.isNotEmpty(card.getBusinessLicensePic()) && ToolUtil.isNotEmpty(card.getFoodBusinessLicensePic())) {
                        //状态 1未提交 2待审核 3已通过 4已驳回
                        card.setStatus(2);
                        card.setCreateTime(new Date());
                    } else {
                        card.setStatus(1);
                    }
                    card.setProId(result.getProId());
                    doubleCardMapper.insert(card);
                }
            }

        List<BtyDoubleCardResult> list1=doubleCardMapper.projectNoDoubleCardList(null);
            if(ToolUtil.isNotEmpty(list1)&&list1.size()>0) {
                for (BtyDoubleCardResult result : list1) {
                    BtyDoubleCard card = new BtyDoubleCard();
                    card.setId(UUIDUtils.getId());
                    card.setGcdm(result.getGcdm());
                    card.setYaoma(result.getYaoma());
                    card.setYyjlTel(result.getYyjlTel());
                    card.setDdTel(result.getDdTel());
                    //根据营运经理电话获取姓名
                    if(ToolUtil.isEmpty(result.getYyjl())){
                        Emp emp=empService.getOne(new QueryWrapper<Emp>().eq("tel",result.getYyjlTel()));
                        if(ToolUtil.isNotEmpty(emp)){
                            card.setYyjl(emp.getXm());
                        }
                    }else{
                        card.setYyjl(result.getYyjl());
                    }

                    //根据督导电话获取姓名
                    if(ToolUtil.isEmpty(result.getDd())){
                        Emp emp=empService.getOne(new QueryWrapper<Emp>().eq("tel",result.getDdTel()));
                        if(ToolUtil.isNotEmpty(emp)){
                            card.setDd(emp.getXm());
                        }
                    }else{
                        card.setDd(result.getDd());
                    }

//                    int proId=result.getProId();
//                    //根据proId查询工程指定督导的时间
//                    List<TaskFlow>flowList=taskFlowService.list(new QueryWrapper<TaskFlow>().eq("task_id",41).eq("pro_id",proId).orderByDesc("create_time"));
//                    if(flowList.size()>0){
//                        card.setCreateTime(flowList.get(0).getCreateTime());
//                    }

                    card.setStatus(1);
                    //状态 1未提交 2待审核 3已通过 4已驳回
                    card.setProId(result.getProId());
                    doubleCardMapper.insert(card);
                }
            }
    }
}

